Fix pytest discovery for tests directory#525
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the test configuration and documentation to integrate a legacy test/ directory alongside the main tests/ suite. Key changes include modifying pytest.ini for broader test discovery and extensively updating tests/README.md with modern execution commands and Poetry-based dependency instructions. Feedback focused on correcting relative paths in documentation examples, avoiding hardcoded tool versions, and maintaining consistency by using Poetry for server execution.
| If you are using the Poetry environment from `api/pyproject.toml` without activating it, run pytest from the repository root with explicit paths: | ||
|
|
||
| ```bash | ||
| poetry -C api run python -m pytest ../tests ../test |
There was a problem hiding this comment.
When running from the repository root, the paths to the test directories should be tests and test relative to the current directory. Using ../ would incorrectly point to directories outside the project root.
| poetry -C api run python -m pytest ../tests ../test | |
| poetry -C api run python -m pytest tests test |
| Install the Python dependencies from the project root: | ||
|
|
||
| ```bash | ||
| python -m pip install poetry==2.0.1 |
There was a problem hiding this comment.
Hardcoding a specific version of Poetry (2.0.1) is restrictive. It is generally better to recommend installing the latest version or a version range (e.g., poetry>=2.0.0) to ensure compatibility with the project's configuration while allowing for updates.
| python -m pip install poetry==2.0.1 | |
| python -m pip install poetry |
| cd api | ||
| python main.py | ||
| ``` No newline at end of file | ||
| python -m api.main |
Summary
pytest.iniso pytest discovers bothtests/and the legacytest/directory.tests/README.mdto match the current test layout and commands.Verification
tests/andtest/.git diff --check.