Review/1365 property test discovery #1385

Merged
xel1uz merged 2 commits from upstream-pr/1385 into main 2026-11-28 14:52:24 +00:00
xel1uz commented 2026-11-24 23:02:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-24T23:02:25Z.


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 #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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481795048 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1385). Originally posted by [xel1uz](https://github.com/xel1uz) on 2026-11-24T23:02:25Z. --- Claimed in the coordination issue as: [TEST-CI-REG-LOCAL-MIXIN](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146307911) (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 #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 - [x] Verified a clean merge against upstream `main` at `28a32e19`. - [x] One topic: make CI registration agree with unittest discovery for local mixins. - [x] No game data, keys or decryption. - Translator contract table: n/a. No translator rule changed.
PierreEbele commented 2026-11-25 15:17:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T15:17:46Z.


Reviewed a1274181a. 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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166615233 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1385#issuecomment-7166615233). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T15:17:46Z. --- Reviewed a1274181a. 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
MoonEyes commented 2026-11-28 14:49:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:49:00Z.


Red/green: test_ci_registration.py failed 2 assertions on main because inherited mixin tests were not counted, and passes with the ancestor-aware defines_a_test.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 4f9199d09 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240952755 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1385#issuecomment-7240952755). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:49:00Z. --- Red/green: test_ci_registration.py failed 2 assertions on main because inherited mixin tests were not counted, and passes with the ancestor-aware defines_a_test. Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 4f9199d09 in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1385
No description provided.