Added utility to print available tests.
parent
f59f881798
commit
90d9658b71
|
@ -480,6 +480,15 @@ options:
|
||||||
--scale SCALE scale factor for the UI
|
--scale SCALE scale factor for the UI
|
||||||
--pyqt6 use PyQt6 rather than PyQt5.
|
--pyqt6 use PyQt6 rather than PyQt5.
|
||||||
--use-x11 force the use of x11 on compatible systems
|
--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).
|
To see the complete list of Qt widgets covered by the unittests, see [Test Coverage](Test%20Coverage.md).
|
||||||
|
|
19
test/ui.py
19
test/ui.py
|
@ -107,6 +107,11 @@ parser.add_argument(
|
||||||
help='force the use of x11 on compatible systems.',
|
help='force the use of x11 on compatible systems.',
|
||||||
action='store_true'
|
action='store_true'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--print-tests',
|
||||||
|
help='print all available tests (widget names).',
|
||||||
|
action='store_true'
|
||||||
|
)
|
||||||
|
|
||||||
args, unknown = parser.parse_known_args()
|
args, unknown = parser.parse_known_args()
|
||||||
if args.pyqt6:
|
if args.pyqt6:
|
||||||
|
@ -2519,13 +2524,21 @@ def test(args, qtargv, test_widget):
|
||||||
def main():
|
def main():
|
||||||
'Application entry point'
|
'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.
|
# Disable garbage collection to avoid runtime errors.
|
||||||
gc.disable()
|
gc.disable()
|
||||||
os.environ['QT_SCALE_FACTOR'] = str(args.scale)
|
os.environ['QT_SCALE_FACTOR'] = str(args.scale)
|
||||||
if args.widget == 'all':
|
if args.widget == 'all':
|
||||||
all_tests = [i for i in globals().keys() if i.startswith('test_')]
|
for widget in widget_names():
|
||||||
all_widgets = [i[len('test_'):] for i in all_tests]
|
|
||||||
for widget in all_widgets:
|
|
||||||
test(args, sys.argv[:1] + unknown, widget)
|
test(args, sys.argv[:1] + unknown, widget)
|
||||||
gc.collect()
|
gc.collect()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue