tests: the CI registration scan counts the tests a TestCase inherits from a class of its module (TEST-CI-REG-LOCAL-MIXIN) #1365

Manually merged
github merged 1 commit from gh-pr/1365/head into gh-pr/1365/base 2026-11-26 09:49:00 +00:00
Owner

@⁠milk4sale on GitHub · 2026-11-24 22:37 UTC · original
milk4sale:test/ci-registration-local-mixin → main · +59 −3 · 1 files · 1 commits · merged 2026-11-24 23:26 UTC

Claimed in the coordination issue as: TEST-CI-REG-LOCAL-MIXIN (#14)

What and why

main is red on tests/test_ci_registration.py since 540d5111f, the merge of #930 at 22:12 UTC on 24 November; the test passes on that commit's parent, 4a50cafc7. The standard-library loop runs this file, so check, stdlib-tests-linux and macos-python fail on every pull request whose run starts on a main from then on.

test_every_selected_file_exposes_a_test_to_its_runner reports #930's tests/semantic/test_sub_co_same_operand.py as a file the semantic job collects nothing from. That is not so: 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 _SameOperandMixin, a plain 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, and not at a base defined in the module, so the fault is in the scan and #930's file stays as it is.

The scan now also counts:

  • the test* methods of the classes of the module that a TestCase derives from, directly or through other classes of the module;
  • a base imported from another module that is reached that way (class Middle(Imported), then class Example(Middle, unittest.TestCase)), as it already did for one the TestCase names itself.

unittest's loader lists a class's tests with dir(), so these are tests the runner runs.

Tested

  • python -I tests/test_ci_registration.py: 16 tests pass on this branch (main 89d7dfcf5 plus the commit). On main alone it fails at test_every_selected_file_exposes_a_test_to_its_runner; at 4a50cafc7 it passes and at 540d5111f it fails.
  • The new test, test_inherited_tests_count_where_unittest_discover_collects_them, does not carry my expectations alone: it writes eight small modules, runs unittest discover on them once and holds the scan to what the runner collected. Five have a test (a mixin above the TestCase, two classes up, beside a TestCase base without tests, an imported mixin named directly and through a local class) and three have none (a base without tests, a mixin no TestCase derives from, a mixin without a TestCase).
  • Control: with main's defines_a_test put back, that test fails in four of the five cases with a test (all but the directly named imported mixin, which main already handled), and the repository check fails as on main.
  • Over the whole repository, at 51a6074d2: both scans list the same 997 test files. Of the 473 files the semantic job selects, main's scan finds a test in 472 and this one in 473; test_sub_co_same_operand.py is the only file the two disagree on, and they agree on all 36 files of the pytest job. unittest's loader collects tests from all 473 semantic files (6191 tests, no import failure). So main's scan disagreed with the runner on that one file, and this one disagrees on none.
  • Every standalone test file under tests/ with python -I (491 files): all pass, where main has the one failure.
  • python -I scripts/check_no_game_data.py tests/test_ci_registration.py, python -m compileall and git diff --check.

Run with Python 3.14.10 on Linux. Not run locally: Python 3.12 (the version CI installs), Windows and macOS. The new test reads unittest's verbose output the way test_semantic_selection_matches_discovery_through_packages in the same file already does.

GPUs tested: n/a (one Python test file; no shader, fixture or runtime code)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code

**@⁠milk4sale** on GitHub · 2026-11-24 22:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1365) `milk4sale:test/ci-registration-local-mixin` → `main` · +59 −3 · 1 files · 1 commits · merged 2026-11-24 23:26 UTC Claimed in the coordination issue as: TEST-CI-REG-LOCAL-MIXIN (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why `main` is red on `tests/test_ci_registration.py` since `540d5111f`, the merge of #930 at 22:12 UTC on 24 November; the test passes on that commit's parent, `4a50cafc7`. The standard-library loop runs this file, so `check`, `stdlib-tests-linux` and `macos-python` fail on every pull request whose run starts on a `main` from then on. `test_every_selected_file_exposes_a_test_to_its_runner` reports #930's `tests/semantic/test_sub_co_same_operand.py` as a file the semantic job collects nothing from. That is not so: `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 `_SameOperandMixin`, a plain 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, and not at a base defined in the module, so the fault is in the scan and #930's file stays as it is. The scan now also counts: - the `test*` methods of the classes of the module that a `TestCase` derives from, directly or through other classes of the module; - a base imported from another module that is reached that way (`class Middle(Imported)`, then `class Example(Middle, unittest.TestCase)`), as it already did for one the `TestCase` names itself. `unittest`'s loader lists a class's tests with `dir()`, so these are tests the runner runs. ### Tested - `python -I tests/test_ci_registration.py`: 16 tests pass on this branch (`main` `89d7dfcf5` plus the commit). On `main` alone it fails at `test_every_selected_file_exposes_a_test_to_its_runner`; at `4a50cafc7` it passes and at `540d5111f` it fails. - The new test, `test_inherited_tests_count_where_unittest_discover_collects_them`, does not carry my expectations alone: it writes eight small modules, runs `unittest discover` on them once and holds the scan to what the runner collected. Five have a test (a mixin above the `TestCase`, two classes up, beside a `TestCase` base without tests, an imported mixin named directly and through a local class) and three have none (a base without tests, a mixin no `TestCase` derives from, a mixin without a `TestCase`). - Control: with `main`'s `defines_a_test` put back, that test fails in four of the five cases with a test (all but the directly named imported mixin, which `main` already handled), and the repository check fails as on `main`. - Over the whole repository, at `51a6074d2`: both scans list the same 997 test files. Of the 473 files the semantic job selects, `main`'s scan finds a test in 472 and this one in 473; `test_sub_co_same_operand.py` is the only file the two disagree on, and they agree on all 36 files of the pytest job. `unittest`'s loader collects tests from all 473 semantic files (6191 tests, no import failure). So `main`'s scan disagreed with the runner on that one file, and this one disagrees on none. - Every standalone test file under `tests/` with `python -I` (491 files): all pass, where `main` has the one failure. - `python -I scripts/check_no_game_data.py tests/test_ci_registration.py`, `python -m compileall` and `git diff --check`. Run with Python 3.14.10 on Linux. Not run locally: Python 3.12 (the version CI installs), Windows and macOS. The new test reads `unittest`'s verbose output the way `test_semantic_selection_matches_discovery_through_packages` in the same file already does. GPUs tested: n/a (one Python test file; no shader, fixture or runtime code) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tests/test_ci_registration.py fails on main since 540d5111f (the merge of #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 51a6074d2: 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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:48:58 +00:00
github manually merged commit fd0a539075 into gh-pr/1365/base 2026-11-26 09:49:00 +00:00
Author
Owner

@⁠milk4sale on GitHub · 2026-11-24 23:01 UTC · original · edited 2026-11-24 23:38 UTC

CI for this commit on my fork, since the queue here is hours behind: https://github.com/milk4sale/leonida/actions/runs/45502632816 (a manual run of the CI workflow on the branch as it is, fd0a53907 on main 89d7dfcf5; Python 3.12).

  • stdlib-tests-linux: success. It fails on main.
  • tests/test_ci_registration.py itself: 16 tests OK on Windows (in check) and on macOS (in macos-python), read from the two job logs. That covers what I had not run locally (Python 3.12, Windows, macOS).
  • semantic-tests (ubuntu-latest) and viewer-tests: success.
  • translator-tests: failure, 2 failed and 1879 passed. They are the two cs_dpp_cmp.asm tests that are red on main since #957; #1375 fixes them.
  • check and macos-python did not finish: both were cancelled at their time limits (15 and 20 minutes), as check was in the five hourly runs of main on the fork before this one. When it was cancelled, check had started 379 of 491 files, and three had failed: tests/test_bink_names.py and tests/test_opus_tags.py (a repr'd Windows path in an error message, which #128 is about) and tests/test_run_wine_tests.py (a KeyError in test_jobs_keeps_locks_serial_tests_and_dependencies, which #1354 added; the same file passes on Windows in the next two runs and fails again in a fourth, #1410 has the cause). None is touched here.

Edited at 23:25 and 23:38 UTC: the first version of this comment named two failing files and left out tests/test_run_wine_tests.py; the second called its error an IndexError and miscounted the later runs.

AI-assisted.

**@⁠milk4sale** on GitHub · 2026-11-24 23:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1365#issuecomment-7146925065) · edited 2026-11-24 23:38 UTC CI for this commit on my fork, since the queue here is hours behind: https://github.com/milk4sale/leonida/actions/runs/45502632816 (a manual run of the `CI` workflow on the branch as it is, `fd0a53907` on `main` `89d7dfcf5`; Python 3.12). - `stdlib-tests-linux`: **success**. It fails on `main`. - `tests/test_ci_registration.py` itself: 16 tests OK on Windows (in `check`) and on macOS (in `macos-python`), read from the two job logs. That covers what I had not run locally (Python 3.12, Windows, macOS). - `semantic-tests (ubuntu-latest)` and `viewer-tests`: success. - `translator-tests`: failure, 2 failed and 1879 passed. They are the two `cs_dpp_cmp.asm` tests that are red on `main` since #957; #1375 fixes them. - `check` and `macos-python` did not finish: both were cancelled at their time limits (15 and 20 minutes), as `check` was in the five hourly runs of `main` on the fork before this one. When it was cancelled, `check` had started 379 of 491 files, and three had failed: `tests/test_bink_names.py` and `tests/test_opus_tags.py` (a repr'd Windows path in an error message, which #128 is about) and `tests/test_run_wine_tests.py` (a `KeyError` in `test_jobs_keeps_locks_serial_tests_and_dependencies`, which #1354 added; the same file passes on Windows in the next two runs and fails again in a fourth, #1410 has the cause). None is touched here. Edited at 23:25 and 23:38 UTC: the first version of this comment named two failing files and left out `tests/test_run_wine_tests.py`; the second called its error an `IndexError` and miscounted the later runs. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 23:26 UTC · original

Merged. Thanks: this turns tests/test_ci_registration.py green on main again.

  • Why it was red: #930 added tests/semantic/test_sub_co_same_operand.py, whose TestCase classes inherit their tests from a mixin in the same file, and the scan counted that file as having no test. I merged #930 without running this file, so that one is on me; it made check, stdlib-tests-linux and macos-python fail on every pull request since.
  • Claim: valid. TEST-CI-REG-LOCAL-MIXIN was posted at 22:30 UTC, before this PR, and is unedited.
  • The fix is right: the scan now walks the base classes defined in the same file, with a visited list so a cycle cannot loop, and counts their test* methods. Over every tests/**/test_*.py, only tests/semantic/test_sub_co_same_operand.py changes its result, from no test to having one. The change can only add tests to a file's count, so no file is newly flagged.
  • tests/test_ci_registration.py: on main 15 tests with 1 failure; with this PR 16 tests, all passing. The new test fails 4 of its cases against main's version of the scan.
  • On main cdb003ea1 + fd0a53907: the semantic suite passes (475 files, 6,220 tests, 0 files failed); the 13 docs and writer tests pass; check_no_game_data.py is clean on the 1 changed files.
  • CI had not finished on this head.

The case of an inherited @property test_* is left to the follow-up #1385.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 23:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1365#issuecomment-7147406483) Merged. Thanks: this turns `tests/test_ci_registration.py` green on `main` again. - **Why it was red:** #930 added `tests/semantic/test_sub_co_same_operand.py`, whose `TestCase` classes inherit their tests from a mixin in the same file, and the scan counted that file as having no test. I merged #930 without running this file, so that one is on me; it made `check`, `stdlib-tests-linux` and `macos-python` fail on every pull request since. - **Claim:** valid. `TEST-CI-REG-LOCAL-MIXIN` was posted at 22:30 UTC, before this PR, and is unedited. - **The fix is right:** the scan now walks the base classes defined in the same file, with a visited list so a cycle cannot loop, and counts their `test*` methods. Over every `tests/**/test_*.py`, only `tests/semantic/test_sub_co_same_operand.py` changes its result, from no test to having one. The change can only add tests to a file's count, so no file is newly flagged. - **`tests/test_ci_registration.py`:** on `main` 15 tests with 1 failure; with this PR 16 tests, all passing. The new test fails 4 of its cases against `main`'s version of the scan. - **On `main` `cdb003ea1` + `fd0a53907`:** the semantic suite passes (475 files, 6,220 tests, 0 files failed); the 13 docs and writer tests pass; `check_no_game_data.py` is clean on the 1 changed files. - **CI had not finished on this head.** The case of an inherited `@property test_*` is left to the follow-up #1385. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.