Tests: sort custom loaded tests (#1851)

This commit is contained in:
Fabian Dill 2023-06-01 01:44:54 +02:00 committed by GitHub
parent c2884e9eb0
commit fad0fe16f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -8,7 +8,13 @@ def load_tests(loader, standard_tests, pattern):
suite.addTests(standard_tests)
folders = [os.path.join(os.path.split(world.__file__)[0], "test")
for world in AutoWorldRegister.world_types.values()]
for folder in folders:
if os.path.exists(folder):
suite.addTests(loader.discover(folder, top_level_dir=file_path))
all_tests = [
test_case for folder in folders if os.path.exists(folder)
for test_collection in loader.discover(folder, top_level_dir=file_path)
for test_suite in test_collection
for test_case in test_suite
]
suite.addTests(sorted(all_tests, key=lambda test: test.__module__))
return suite