Skip to content

Review/1365 property test discovery - #1385

Open
xel1uz wants to merge 2 commits into
ProjectLeonida:mainfrom
xel1uz:review/1365-property-test-discovery
Open

xel1uz wants to merge 2 commits into
ProjectLeonida:mainfrom
xel1uz:review/1365-property-test-discovery

Conversation

@xel1uz

@xel1uz xel1uz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 TestCase that inherits only @property def test_label(self) can pass the CI registration check even though unittest discovers zero tests. The scanner sees the test prefix on the function definition, but looking up the name on the class returns a property.

The follow-up teaches the scanner to recognize @property and its getter, setter, and deleter forms. It adds two cases checked against real unittest discovery: an inherited property with a setter contributes zero tests, while an inherited @staticmethod def test_one() contributes one.

Tested

  • Reproduced the mismatch on the original PR at fd0a5390: the registration check accepted the property-only mixin, while unittest collected zero tests.
  • On a1274181, the scanner agreed with unittest in both new cases. Ran py -3.12 -I tests/test_ci_registration.py on Windows with Python 3.12.10: all 16 tests passed.
  • On the original PR, also ran 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 --check and scripts/check_no_game_data.py passed for the changed file.

GPUs tested: n/a (Python test discovery).

AI-assisted: yes, OpenAI Codex.

Checklist

  • Verified a clean merge against upstream main at 28a32e19.
  • One topic: make CI registration agree with unittest discovery for local mixins.
  • No game data, keys or decryption.
  • Translator contract table: n/a. No translator rule changed.

milk4sale and others added 2 commits November 24, 2026 16:36
…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>
@PierreEbele

Copy link
Copy Markdown
Contributor

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 python -m unittest discover collects nothing; the PR agrees with the runner in every case, and the staticmethod fixture keeps counting. Two leftover false positives predate this PR and are unchanged by it (functools.cached_property, and @Mixin.test_x.setter written in a subclass); worth a finding line in the coordination issue, no change requested here.

AI-assisted review.

Recommendation: Merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants