--- description: Unit test file naming and placement conventions globs: tests/**/*.py alwaysApply: false --- # Test Organization Unit tests use a one-to-one mapping between source modules and test files. ## Naming - `python_repositories//.py` → `tests/unit/_test.py` - Test files must end with `_test.py` (enforced by pre-commit `name-tests-test`) ## Placement - Add tests to the existing `*_test.py` for the module under test - Do not create cross-cutting test files (e.g. `structural_typing_test.py`); colocate with the relevant interface/adapter/config test file - Shared fixtures → `tests/conftest.py` - Module-specific helper classes → the matching test file ## Examples ``` json_repository_interface.py → tests/unit/json_repository_interface_test.py redis_adapter.py → tests/unit/redis_adapter_test.py redis_config.py → tests/unit/redis_config_test.py ``` Integration tests live under `tests/integration//` with the same `_test.py` suffix.