run_tests.py wasn't actually running any tests. #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing run_tests.py
run_tests.pywasn't actually causing any tests to run. This change fixes that, but it is worth examining why it had stopped working. Analysis performed and write-up up by Claude, reviewed by Bill PughHistory of run_tests.py and Why It Broke
Original working version (commits b7281c4 and 092458c):
How it worked:
Broken version (commit 9d2363b - Feb 2024 "add pre-commit hooks"):
What changed:
Why it was removed:
The Fix:
The solution uses the proper unittest API for test discovery:
This is the correct way to discover tests in a separate directory. It doesn't rely on namespace pollution from import *.
So yes, unittest.main() worked in the past, but only because of the from tests.test_parser import * hack. When that was removed for
code quality reasons, the test runner broke.