fix(pytest): configure pythonpath and testpaths for optional pytest discovery - #88
Open
louzt wants to merge 2 commits into
Open
fix(pytest): configure pythonpath and testpaths for optional pytest discovery#88louzt wants to merge 2 commits into
louzt wants to merge 2 commits into
Conversation
…iscovery
Adds [tool.pytest.ini_options] with pythonpath = ["src"] and
testpaths = ["tests"] so developers who prefer pytest can run
`pytest tests/unit` directly without PYTHONPATH overrides.
This is additive DX. CI continues to run via the unittest discover
workflow per AGENTS.md §Pre-PR checklist:
uv run python -m unittest discover -s tests/unit -v
Scope Boundary:
- Does NOT change the build system (hatchling only).
- Does NOT change CI workflows.
- Does NOT enable any markers that would require --strict-markers
(left unset to avoid regressing tests with unregistered markers).
Validation:
$ uv run pytest tests/unit
Ran 111 tests in 5.000s
OK
Greptile SummaryAdds optional local pytest support while keeping CI on unittest.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(pytest): declare pytest dev dep and ..." | Re-trigger Greptile |
…t (PR appwrite#88 review) Greptile flagged appwrite#88 pyproject.toml:67-69 as P1+P2: P1 (pytest not declared): 'uv run pytest tests/unit' failed in a fresh clone because pytest was absent from every dependency group. CI does not depend on this — AGENTS.md drives the unit suite via 'python -m unittest discover -s tests/unit', and the integration suite runs only on same-repo pushes — but a developer typing 'uv run pytest tests/unit' after 'uv sync --group dev' should not see 'command not found'. P2 (testpaths crossed the unit/integration boundary): 'testpaths = ["tests"]' meant a bare 'pytest' invocation also discovered 'tests/integration/', which needs the '--extra integration' extras and live Appwrite credentials (per AGENTS.md §Local development). Worse, when both extras and credentials are present, bare pytest would hit live Appwrite endpoints — a side-effect a developer almost never intends. Fixes: - Add 'pytest>=8.0' to '[dependency-groups].dev' with a comment that flags it as optional and explains the CI matrix. - Change 'testpaths = ["tests"]' to 'testpaths = ["tests/unit"]' so bare pytest only collects the unit suite by default. Integration tests still run via an explicit 'uv sync --extra integration && uv run --extra integration pytest -m integration tests/integration' invocation. CI: ruff ✓, black ✓, pyright ✓, unittest discover 98/98 ✓, 'uv run pytest tests/unit' 98/98 ✓ (and confirms the testpaths narrowing — only tests/unit collected, integration tree skipped).
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.
Summary
Adds
[tool.pytest.ini_options]topyproject.tomlso developers whoprefer pytest can run
pytest tests/unitdirectly after cloning, withoutPYTHONPATH=srcoverrides or other env workarounds.Rationale
AGENTS.md§Pre-PR checklist documents that CI runs the test suitevia:
This works because
python -m unittestresolves the package relativeto the project root. However, a developer who prefers pytest style
(
pytest tests/unit) currently hitsModuleNotFoundError: No module named 'mcp_server_appwrite'unless they manually exportPYTHONPATH=src. This PR removes that friction.Changes
That's it. Two keys, three lines (with section header).
Scope Boundary
This PR is strictly additive DX. It does NOT:
hatchlingonly).python -m unittest discover).--strict-markers(would regress tests with unregistered markers).[tool.pytest.*]config that conflicts withpyrightorruff.Validation
Compatibility
Pytest is already installed transitively via the dev group
(
uv sync --group dev). No new dependencies are introduced.Discussion
If maintainers prefer to keep the test framework purely on unittest
and not advertise pytest, this PR can be closed without impact — both
unittest discoverandpytestwill continue to work, since theconfig is additive.
If accepted, a follow-up could explore migrating individual test
modules to pytest-style
assertstatements for readability, but thatis intentionally out of scope here.
Review feedback resolution
Greptile Bot reviewed this PR and reported the following two issues,
both fixed in the head commit
68f6371:pyproject.toml:67-69pytestwas absent from every dependency group.pyproject.toml:69testpaths = ["tests"]made barepytesttraverse the integration suite.Fix 1 — declare
pytestas an optional dev dependencyAdded
pytest>=8.0to[dependency-groups].devwith a comment thatflags it as optional and explains that CI does not depend on it
(per
AGENTS.md§Pre-PR checklist, the unit job usespython -m unittest discover -s tests/unitand the integration job runs only onsame-repo pushes). A developer who types
uv run pytest tests/unitafter
uv sync --group devno longer sees a "command not found"surprise:
Fix 2 — narrow
testpathsto the unit suiteChanged
testpaths = ["tests"]totestpaths = ["tests/unit"]so abare
uv run pytestfrom a fresh clone only collects unit tests. Theintegration suite still runs under an explicit
uv sync --extra integration && uv run --extra integration pytest -m integration tests/integrationinvocation. This prevents two failuremodes Greptile identified:
integrationextra installed, pytest would try to
importintegration modulesthat pull in
argon2-cffi,bcrypt,passlib,pycryptodome(declared in
[project.optional-dependencies].integration) andfail with
ModuleNotFoundError.APPWRITE_PROJECT_ID/APPWRITE_API_KEYcredentials happen to bepresent, bare pytest would silently dispatch real create/delete
calls to Appwrite Cloud — an unintended side-effect a developer
almost never wants from a "run my tests" command.
Verification
Both
[project.optional-dependencies].integrationand thetests/integration/tree are intentionally left untouched; theyremain separately provisioned exactly as before. This PR only narrows
the default discovery root of
pytestso it does not accidentallytraverse them.
Summary by CodeRabbit