Review/1365 property test discovery #1385

Open
github-bot wants to merge 1 commit from github-bot/gh-1385 into main AGit
Owner

@⁠xel1uz on GitHub · 2026-11-24 23:02 UTC · original
xel1uz:review/1365-property-test-discovery → main · +80 −5 · 1 files · 2 commits · open

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.
**@⁠xel1uz** on GitHub · 2026-11-24 23:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1385) `xel1uz:review/1365-property-test-discovery` → `main` · +80 −5 · 1 files · 2 commits · open Claimed in the coordination issue as: [TEST-CI-REG-LOCAL-MIXIN](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) (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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:49:35 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:17 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 15:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1385#issuecomment-7166615233) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1385/head:github-bot/gh-1385'
git switch 'github-bot/gh-1385'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1385'
git switch 'github-bot/gh-1385'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1385'
git switch 'github-bot/gh-1385'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1385'
git switch 'main'
git merge --squash 'github-bot/gh-1385'
git switch 'main'
git merge --ff-only 'github-bot/gh-1385'
git switch 'main'
git merge 'github-bot/gh-1385'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.