From 25ecfdabf4d974664ff4b6673668c4e8d04584f0 Mon Sep 17 00:00:00 2001 From: louzt Date: Mon, 27 Jul 2026 10:33:53 -0600 Subject: [PATCH 1/2] fix(pytest): configure pythonpath and testpaths for optional pytest discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bc451cf..4db911a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,10 @@ venvPath = "." venv = ".venv" typeCheckingMode = "basic" +[tool.pytest.ini_options] +pythonpath = ["src"] +testpaths = ["tests"] + [build-system] requires = ["hatchling"] build-backend = "hatchling.build" From 68f63718e557a6f80c1d7a1e5bd9bbc9dd8b4090 Mon Sep 17 00:00:00 2001 From: louzt Date: Mon, 27 Jul 2026 12:08:32 -0600 Subject: [PATCH 2/2] fix(pytest): declare pytest dev dep and narrow testpaths to tests/unit (PR #88 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Greptile flagged appwrite/mcp#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). --- pyproject.toml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4db911a..a2dc0b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,12 @@ dev = [ "pyright>=1.1.390", # Only needed by scripts/build_docs_index.py to (re)build the docs index. "pyyaml>=6.0", + # Optional local runner. The CI matrix (AGENTS.md) drives the unit suite + # with `python -m unittest discover -s tests/unit` and the integration + # suite on same-repo pushes only; pytest is installed here purely so a + # developer who types `uv run pytest tests/unit` after `uv sync --group + # dev` doesn't get a "command not found" surprise. + "pytest>=8.0", ] [project.scripts] @@ -65,8 +71,20 @@ venv = ".venv" typeCheckingMode = "basic" [tool.pytest.ini_options] +# Place `src` on the import path so `pytest` can resolve `mcp_server_appwrite` +# without a manual `PYTHONPATH` override. The CI unit job does not depend on +# this — it uses `python -m unittest discover -s tests/unit` per AGENTS.md. pythonpath = ["src"] -testpaths = ["tests"] +# Default discovery root is narrowed to the **unit** suite so a bare +# `uv run pytest` from a fresh `uv sync --group dev` does *not* traverse +# `tests/integration/`. The integration suite needs `--extra integration` +# and live Appwrite credentials (see AGENTS.md §Local development / §Unit +# tests); letting pytest pick it up by default would import-error on the +# integration extras in a fresh clone and, worse, hit live Appwrite +# endpoints when credentials are present. Run it explicitly with +# `uv sync --extra integration && uv run --extra integration pytest -m +# integration tests/integration` when ready. +testpaths = ["tests/unit"] [build-system] requires = ["hatchling"]