mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make calibre-debug --run-test a bit smarter
This commit is contained in:
parent
4654742f87
commit
cc2d5c23f5
@ -103,7 +103,10 @@ Everything after the -- is passed to the script.
|
||||
'calibre-debug -r "Plugin name" -- file1 --option1\n'
|
||||
'Everything after the -- will be passed to the plugin as arguments.'))
|
||||
parser.add_option('-t', '--run-test', help=_(
|
||||
'Run the named test(s)'))
|
||||
'Run the named test(s). Use the special value "all" to run all tests.'
|
||||
' If the test name starts with a period it is assumed to be a module name.'
|
||||
' If the test name starts with @ it is assumed to be a category name.'
|
||||
))
|
||||
parser.add_option('--diff', action='store_true', default=False, help=_(
|
||||
'Run the calibre diff tool. For example:\n'
|
||||
'calibre-debug --diff file1 file2'))
|
||||
|
@ -302,7 +302,16 @@ def find_tests(which_tests=None, exclude_tests=None):
|
||||
|
||||
def run_test(test_name, verbosity=4, buffer=False):
|
||||
# calibre-debug -t test_name
|
||||
tests = find_tests()
|
||||
which_tests = None
|
||||
if test_name.startswith('@'):
|
||||
which_tests = test_name[1:],
|
||||
tests = find_tests(which_tests)
|
||||
if test_name != 'all':
|
||||
if test_name.startswith('.'):
|
||||
tests = filter_tests_by_module(tests, test_name[1:])
|
||||
elif test_name.startswith('@'):
|
||||
pass
|
||||
else:
|
||||
tests = filter_tests_by_name(tests, test_name)
|
||||
if not tests._tests:
|
||||
raise SystemExit(f'No test named {test_name} found')
|
||||
|
Loading…
x
Reference in New Issue
Block a user