Added utility to print available tests.

main
Alex Huszagh 2022-05-01 10:23:30 -05:00
parent f59f881798
commit 90d9658b71
2 changed files with 25 additions and 3 deletions

View File

@ -480,6 +480,15 @@ options:
--scale SCALE scale factor for the UI
--pyqt6 use PyQt6 rather than PyQt5.
--use-x11 force the use of x11 on compatible systems
--print-tests print all available tests (widget names).
# Get a complete list of available tests.
$ python test/ui.py --print-tests
aero_wizard
all_focus_tree
alpha_colordialog
...
wizard
yes_button
```
To see the complete list of Qt widgets covered by the unittests, see [Test Coverage](Test%20Coverage.md).

View File

@ -107,6 +107,11 @@ parser.add_argument(
help='force the use of x11 on compatible systems.',
action='store_true'
)
parser.add_argument(
'--print-tests',
help='print all available tests (widget names).',
action='store_true'
)
args, unknown = parser.parse_known_args()
if args.pyqt6:
@ -2519,13 +2524,21 @@ def test(args, qtargv, test_widget):
def main():
'Application entry point'
def test_names():
return [i for i in globals().keys() if i.startswith('test_')]
def widget_names():
return [i[len('test_'):] for i in test_names()]
if args.print_tests:
print('\n'.join(sorted(widget_names())))
return 0
# Disable garbage collection to avoid runtime errors.
gc.disable()
os.environ['QT_SCALE_FACTOR'] = str(args.scale)
if args.widget == 'all':
all_tests = [i for i in globals().keys() if i.startswith('test_')]
all_widgets = [i[len('test_'):] for i in all_tests]
for widget in all_widgets:
for widget in widget_names():
test(args, sys.argv[:1] + unknown, widget)
gc.collect()
else: