Observation
main.py runs work at import time. Its argument parsing, its LocationService /
EnvironmentService construction and the bare main() call at the bottom of the file
all execute as soon as the module is imported:
locationService = LocationService(url, port)
environmentService = EnvironmentService(url, port)
...
main()
There is no if __name__ == "__main__": guard.
Consequence
The module cannot be imported by a test without the whole program running, so nothing
in main.py can be covered by the tests/ suite introduced in PR #10 — including the
RenderWindow-driven render loop that PR refactors, the environments.json cache-key
logic, and the --exit-after-create early-return path. The refactor in PR #10 was
therefore validated only by a hand-built headless harness that stubbed the Viron
services and injected the module chain into sys.modules, which is not something a
reviewer can re-run from the repository.
Suggested change
- Guard the entry point with
if __name__ == "__main__": so importing the module has
no side effects. python main.py is unaffected, since the module is __main__ in
that case, and create_environments.bat invokes it the same way.
- Move the module-level argument parsing and service construction into a function
(for example parse_args() and a main(gridSize, exitAfterCreate, ...) signature),
so a test can drive main() with mocked services.
- Add
tests/test_main.py covering, at minimum, the grid-size fallback on unparseable
input, the environments.json cache key, and loop termination on QUIT.
Scope note
This is a refactor of the entry point rather than a behavior change, and it touches the
live render loop, so the project's live-Viron manual-validation anchor is expected to be
required for it.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
Observation
main.pyruns work at import time. Its argument parsing, itsLocationService/EnvironmentServiceconstruction and the baremain()call at the bottom of the fileall execute as soon as the module is imported:
There is no
if __name__ == "__main__":guard.Consequence
The module cannot be imported by a test without the whole program running, so nothing
in
main.pycan be covered by thetests/suite introduced in PR #10 — including theRenderWindow-driven render loop that PR refactors, theenvironments.jsoncache-keylogic, and the
--exit-after-createearly-return path. The refactor in PR #10 wastherefore validated only by a hand-built headless harness that stubbed the Viron
services and injected the module chain into
sys.modules, which is not something areviewer can re-run from the repository.
Suggested change
if __name__ == "__main__":so importing the module hasno side effects.
python main.pyis unaffected, since the module is__main__inthat case, and
create_environments.batinvokes it the same way.(for example
parse_args()and amain(gridSize, exitAfterCreate, ...)signature),so a test can drive
main()with mocked services.tests/test_main.pycovering, at minimum, the grid-size fallback on unparseableinput, the
environments.jsoncache key, and loop termination onQUIT.Scope note
This is a refactor of the entry point rather than a behavior change, and it touches the
live render loop, so the project's live-Viron manual-validation anchor is expected to be
required for it.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson