Skip to content

Tests: sort custom loaded tests #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/worlds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
all_tests = []
for folder in folders:
if os.path.exists(folder):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would invert this if due to the very high nesting in this section

suite.addTests(loader.discover(folder, top_level_dir=file_path))
for test_collection in loader.discover(folder, top_level_dir=file_path):
for test_suite in test_collection:
for test_case in test_suite:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use all_tests.extend(test_suite) to avoid one level of nesting?

all_tests.append(test_case)

suite.addTests(sorted(all_tests, key=lambda test: test.__module__))
return suite