Skip to content

test_game_profile.py run as a file skipped the four BuildModules tests - #2110

Open
oliverames wants to merge 2 commits into
seedds:mainfrom
oliverames:test-game-profile-main-guard
Open

oliverames wants to merge 2 commits into
seedds:mainfrom
oliverames:test-game-profile-main-guard

Conversation

@oliverames

@oliverames oliverames commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Run as a file, python3 dm/tools/tests/test_game_profile.py reports 3 tests and OK, but the file defines 7. The if __name__ == '__main__' block sits above the BuildModules class, so unittest.main() collects the tests before that class exists and then ends the interpreter. The four BuildModules tests (the build rows' module lists) never run that way.

CI isn't affected: the tests workflow runs python -m unittest <file>, which imports the whole module first and runs all 7. This only bites a local run of the file, which is how I noticed it: a count I'd quoted in #1217 didn't match.

The change moves the guard to the end of the file. Nothing else changes.

Checked

  • Tests: python3 dm/tools/tests/test_game_profile.py -v now runs 7 tests, all passing (3 before). python3 -m unittest -v dm/tools/tests/test_game_profile.py runs the same 7 as before. I scanned all 176 test_*.py files in the repository for a class or function after the main guard: this was the only one.
  • python3 dm/tools/lint_python.py --against origin/main with the pinned tools: 339 findings, 336 in the baseline, 3 new. All three are main's own, in dm/gfx/tools/dmsh_build.py lines 166 and 167; none is in this file. Main has since fixed them (3ade2f2ef).
  • Games run, with title ID and version: none. A test file only.
  • Devices and OS: an Apple silicon Mac, macOS 27.3, Python 3.14 and 3.15.
  • scripts/regress.py check --games: not run. No host, shader or tool code changes.

Docs

  • The finding is in its game note or its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index). Not applicable: no finding about a game or a subsystem.
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change. Not applicable.
  • No game files, keys or data extracted from a game in the change or the attachments

@github-actions github-actions Bot added the tools Tools and scripts (dm/tools, scripts) label Nov 10, 2026
…s: its main guard sat above that class

Run as `python3 dm/tools/tests/test_game_profile.py`, the file reported 3 tests and
OK. The `if __name__ == '__main__'` block called unittest.main() above the BuildModules
class, so that class was not defined yet when the tests were collected, and
unittest.main() ends the interpreter when it is done. The tests workflow was not
affected: it runs `python -m unittest <file>`, which imports the whole module first and
runs all 7.

The guard moves to the end of the file. Run as a file it now reports 7 tests, all
passing, and `python -m unittest` reports the same 7 as before. No other test_*.py in
the repository has a class or a function after its guard.
@oliverames
oliverames force-pushed the test-game-profile-main-guard branch from 080af24 to 49c4a12 Compare November 10, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant