Repository navigation
test_game_profile.py run as a file skipped the four BuildModules tests - #2110
Open
oliverames wants to merge 2 commits into
Open
oliverames wants to merge 2 commits into
oliverames wants to merge 2 commits into
Conversation
…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
force-pushed
the
test-game-profile-main-guard
branch
from
November 10, 2026 14:04
080af24 to
49c4a12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Run as a file,
python3 dm/tools/tests/test_game_profile.pyreports 3 tests and OK, but the file defines 7. Theif __name__ == '__main__'block sits above theBuildModulesclass, sounittest.main()collects the tests before that class exists and then ends the interpreter. The fourBuildModulestests (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
python3 dm/tools/tests/test_game_profile.py -vnow runs 7 tests, all passing (3 before).python3 -m unittest -v dm/tools/tests/test_game_profile.pyruns the same 7 as before. I scanned all 176test_*.pyfiles 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/mainwith the pinned tools: 339 findings, 336 in the baseline, 3 new. All three are main's own, indm/gfx/tools/dmsh_build.pylines 166 and 167; none is in this file. Main has since fixed them (3ade2f2ef).scripts/regress.py check --games: not run. No host, shader or tool code changes.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index). Not applicable: no finding about a game or a subsystem.dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change. Not applicable.