Repository navigation
Conversation
…from a class of its module (TEST-CI-REG-LOCAL-MIXIN) tests/test_ci_registration.py fails on main since 540d511 (the merge of ProjectLeonida#930) and passes on its parent: test_every_selected_file_exposes_a_test_to_its_runner reports tests/semantic/test_sub_co_same_operand.py as a file the semantic job collects nothing from. `python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py` runs 6 tests there. Its three TestCase classes have no test method of their own: they take them from a mixin class defined in the same file, one TestCase per wave size. defines_a_test looked at a TestCase's own body and at a base imported from another module, not at a base defined in the module. It now also counts the test* methods of the classes of the module a TestCase derives from, directly or through other classes of the module, and an imported base reached that way. unittest's loader lists a class's tests with dir(), so these are the tests it runs. The new test writes eight small modules, runs unittest discover on them once and holds the scan to what the runner collected: a mixin above the TestCase, two classes up, beside a TestCase base without tests, an imported mixin named directly and through a local class (a test each), and a base without tests, a mixin no TestCase derives from and a mixin without a TestCase (none). With main's defines_a_test put back, four of the five cases with a test fail, and so does the repository check. Over the repository at 51a6074: the scan lists the same 997 test files; of the 473 the semantic job selects, main's scan found a test in 472 and this one in 473, and test_sub_co_same_operand.py is the only file the two disagree on (none of the pytest job's 36). unittest's loader collects tests from all 473 (6191 tests, no import failure), so main's scan disagreed with the runner on that one file and this one on none. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AI-assisted: OpenAI Codex.
|
Reviewed a127418. One-file change in tests/test_ci_registration.py: test-name detection learns that a property and its accessors are not test methods, which matches unittest's loader (getattr on the class is not callable). Ran (Python 3.12) the full file on the PR tree, 16 tests OK including the two new fixtures and the Ran-6 count, and the file on main, 16 tests OK with the old logic. A probe on both trees confirms the fix: for the property-only mixin source (and plain-def-shadowed-by-property, cross-name setters, property-over-staticmethod) main's scan says the file defines a test while a real AI-assisted review. Recommendation: Merge |
Claimed in the coordination issue as: TEST-CI-REG-LOCAL-MIXIN (original claim by @milk4sale).
Depends on: #1365. This branch includes @milk4sale's support for test methods inherited from a mixin in the same module.
What and why
On #1365, a
TestCasethat inherits only@property def test_label(self)can pass the CI registration check even thoughunittestdiscovers zero tests. The scanner sees thetestprefix on the function definition, but looking up the name on the class returns a property.The follow-up teaches the scanner to recognize
@propertyand its getter, setter, and deleter forms. It adds two cases checked against realunittestdiscovery: an inherited property with a setter contributes zero tests, while an inherited@staticmethod def test_one()contributes one.Tested
fd0a5390: the registration check accepted the property-only mixin, whileunittestcollected zero tests.a1274181, the scanner agreed withunittestin both new cases. Ranpy -3.12 -I tests/test_ci_registration.pyon Windows with Python 3.12.10: all 16 tests passed.py -3.12 -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py -v: all six tests in the module that motivated tests: the CI registration scan counts the tests a TestCase inherits from a class of its module (TEST-CI-REG-LOCAL-MIXIN) #1365 passed.git diff --checkandscripts/check_no_game_data.pypassed for the changed file.GPUs tested: n/a (Python test discovery).
AI-assisted: yes, OpenAI Codex.
Checklist
mainat28a32e19.