Proper location for ensure_app when running srv tests

This commit is contained in:
Kovid Goyal 2016-06-21 23:40:04 +05:30
parent 18792fb11a
commit ceeb2b21f9
3 changed files with 5 additions and 4 deletions

View File

@ -83,8 +83,6 @@ class Test(Command):
' can be run by specifying the name "something".') ' can be run by specifying the name "something".')
def run(self, opts): def run(self, opts):
from calibre.gui2 import ensure_app, load_builtin_fonts
ensure_app(), load_builtin_fonts()
r = unittest.TextTestRunner r = unittest.TextTestRunner
tests = find_tests(which_tests=frozenset(opts.test_module)) tests = find_tests(which_tests=frozenset(opts.test_module))
if opts.test_name: if opts.test_name:

View File

@ -15,6 +15,11 @@ from calibre.srv.tests.base import LibraryBaseTest
from calibre.utils.imghdr import identify from calibre.utils.imghdr import identify
from calibre.utils.shared_file import share_open, test as test_share_open from calibre.utils.shared_file import share_open, test as test_share_open
def setUpModule():
# Needed for cover generation
from calibre.gui2 import ensure_app, load_builtin_fonts
ensure_app(), load_builtin_fonts()
class ContentTest(LibraryBaseTest): class ContentTest(LibraryBaseTest):
def test_static(self): # {{{ def test_static(self): # {{{

View File

@ -63,8 +63,6 @@ def find_tests():
return unittest.TestSuite(suits) return unittest.TestSuite(suits)
def run_tests(find_tests=find_tests): def run_tests(find_tests=find_tests):
from calibre.gui2 import ensure_app, load_builtin_fonts
ensure_app(), load_builtin_fonts() # needed for dynamic cover generation
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('name', nargs='?', default=None, parser.add_argument('name', nargs='?', default=None,
help='The name of the test to run, for e.g. writing.WritingTest.many_many_basic or .many_many_basic for a shortcut') help='The name of the test to run, for e.g. writing.WritingTest.many_many_basic or .many_many_basic for a shortcut')