Skip to content

Make the Python client test suite runnable and document how to run it - #205

Merged
dmccoystephenson merged 5 commits into
mainfrom
feature/python-client-test-runnability
Aug 12, 2026
Merged

dmccoystephenson merged 5 commits into
mainfrom
feature/python-client-test-runnability

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • pytest.ini's pythonpath is pointed at the repository root. The previous value listed the package directories themselves, which supports preponderous.viron... imports, whereas the client source and all eight test modules import through src.main.python.preponderous.viron... — so every test module failed collection with ModuleNotFoundError: No module named 'src'. Of the two ways out described in pytest fails to collect the Python client tests: pytest.ini's pythonpath does not match the tests' import style #201, the root was chosen deliberately: the alternative (rewriting the imports to preponderous.viron...) would have to change the client's own internal imports too, and that is the path external consumers import by, so it is an API decision rather than a test-configuration one. testpaths is also pinned so a bare pytest run picks up only the client suite.
  • environmentService.get_all_environments is annotated with typing.List instead of the builtin generic list[Environment], matching all three sibling services. Builtin generics in annotations are evaluated when the class body runs and are not subscriptable before Python 3.9, so EnvironmentService could not be imported at all on 3.8 and test_environmentService.py could not be collected.
  • The README's Testing section now documents the client suite, its Python and dependency requirements, why the root is on the path, and that CI covers the Java build only. The project-structure listing gains src/test/python/.

Test plan

Notes on the rest of the backlog

Deferred this cycle, with reasons recorded here per the loop's auditability rule:

  • moveEntityToLocation's collision check is a read-then-write race the database cannot settle #203 (moveEntityToLocation's read-then-write race) — the issue's own acceptance criteria are gated on a design decision that is not the loop's to make: whether one-entity-per-location is meant to be a real invariant of the data or a rule of that one endpoint. addEntityToLocation currently ignores occupancy entirely, so either answer implies changes beyond the reported endpoint. A conditional-write fix (option 3) is implementable without settling that question and is the recommended next step once the question is answered.
  • Wire OpenAPI-first codegen / spec-drift guard (rebuild-plan hygiene gap) #130 (OpenAPI-first codegen / spec-drift guard) — build and CI infrastructure touching pom.xml and .github/workflows/, both on the do-not-auto-merge list, and larger than a polish-sized PR.

CI runs ./mvnw compile and ./mvnw test only, so a green run does not exercise any file changed here except by proving the Java build is unaffected; the Python verification above was performed locally.

Closes #201
Closes #204

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 5 commits August 12, 2026 01:06
…lect

pytest.ini listed the package directories themselves, which supports
preponderous.viron... imports, while the client and every test module import
through src.main.python.preponderous.viron... and need the root instead. All
eight test modules failed collection with ModuleNotFoundError: No module named
'src'. Point pythonpath at the root to match the import style already in use,
and pin testpaths so a bare pytest run only picks up the client suite.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
environmentService was the only service using a PEP 585 builtin generic
(list[Environment]); its siblings all use typing.List. Builtin generics in
annotations are evaluated when the class body runs and are not subscriptable
before Python 3.9, so importing EnvironmentService raised TypeError there and
test_environmentService.py could not be collected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The README mentioned the client directory but never said how to test it, and
did not note that CI covers the Java build only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… pytest

testpaths changed nothing measurable: a bare pytest run collects the same 107
tests without it, since no other test_*.py exists in the tree. The README now
also records that pytest.ini's pythonpath setting arrived in pytest 7.0, so the
6.2.4 pinned by requirements.txt ignores it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric, scored against the diff at 29853d6 and the command output named in each line. Items are scored FAIL unless direct evidence of PASS was produced.

Findings folded in from outside the rubric

  • requirements.txt pins pytest==6.2.4, which predates the pythonpath ini setting (introduced in pytest 7.0). A developer installing from that file therefore still hits the original collection failure, because the key is silently ignored. This was not verified by execution — a virtualenv could not be created in this environment (ensurepip is not available), so the claim rests on pytest's changelog rather than an observed run, and it is asserted in the README on that basis. The pin itself is left alone because requirements.txt is a dependency surface this repository's automation holds back from autonomous change; it is filed as requirements.txt pins a pytest older than the pythonpath setting the test suite depends on #206 and the README carries an explicit warning in the meantime.
  • The two verified interpreter/pytest combinations differ, which is worth stating so later readers are not misled: pytest on this machine is 9.0.3 running on 3.9+, while python3 -m pytest is 7.1.3 on 3.8.10. Both pass all 107 tests with this branch applied.

One intrinsic-critique pass; no further self-scoring will follow absent a reviewer comment or a CI failure.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 64addfb into main Aug 12, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/python-client-test-runnability branch August 12, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant