@@ -35,19 +35,19 @@ tests/
3535
3636** Requirements:**
3737``` bash
38- # Python 3.10+ with pytest
39- python3 --version # 3.10, 3.11, 3.12, 3.14 tested
38+ # Python 3.14+ with uv package manager
39+ python3 --version # 3.14 required
40+ uv --version # uv required
4041
41- # Install test dependencies
42- pip install -e " .[dev]"
43- # OR
44- uv pip install -e " .[dev]"
42+ # Sync all dependencies (including dev)
43+ uv sync --extra dev
4544```
4645
4746** Test dependencies (from pyproject.toml):**
4847- pytest — Test framework
4948- pytest-cov — Coverage reporting
50- - pytest-mock — Mocking utilities (if used)
49+ - pytest-mock — Mocking utilities
50+ - pytest-xdist — Parallel test execution
5151
5252** Test environment variables:**
5353``` bash
@@ -58,33 +58,36 @@ CLI_AUDIT_TIMEOUT_SECONDS=1 # Fast timeout for tests
5858
5959## Build & tests
6060
61- ** Run all tests:**
61+ ** Run all tests (use uv run) :**
6262``` bash
63- # From project root
64- python3 -m pytest tests/ -v
63+ # From project root - ALWAYS use uv run
64+ uv run python -m pytest
65+
66+ # Verbose output
67+ uv run python -m pytest -v
6568
6669# With coverage
67- python3 -m pytest tests/ -v --cov=cli_audit --cov-report=html
70+ uv run python -m pytest --cov=cli_audit --cov-report=html
6871
69- # Parallel execution
70- python3 -m pytest tests/ -v -n auto
72+ # Parallel execution (fast)
73+ uv run python -m pytest -n auto
7174```
7275
7376** Run specific test files:**
7477``` bash
7578# Single test file
76- python3 -m pytest tests/test_config.py -v
79+ uv run python -m pytest tests/test_config.py -v
7780
7881# Single test class
79- python3 -m pytest tests/test_config.py::TestToolConfig -v
82+ uv run python -m pytest tests/test_config.py::TestToolConfig -v
8083
8184# Single test function
82- python3 -m pytest tests/test_config.py::TestToolConfig::test_tool_config_defaults -v
85+ uv run python -m pytest tests/test_config.py::TestToolConfig::test_tool_config_defaults -v
8386```
8487
8588** Run integration tests:**
8689``` bash
87- python3 -m pytest tests/integration/ -v
90+ uv run python -m pytest tests/integration/ -v
8891```
8992
9093** Smoke test (quick validation):**
@@ -95,13 +98,13 @@ python3 -m pytest tests/integration/ -v
9598** Filter tests by marker:**
9699``` bash
97100# Run only slow tests
98- python3 -m pytest -m slow
101+ uv run python -m pytest -m slow
99102
100103# Skip slow tests
101- python3 -m pytest -m " not slow"
104+ uv run python -m pytest -m " not slow"
102105
103106# Run only unit tests
104- python3 -m pytest -m unit
107+ uv run python -m pytest -m unit
105108```
106109
107110## Code style & conventions
@@ -206,7 +209,7 @@ def test_tool_execution(mock_run):
206209
207210Before committing test changes:
208211
209- - [ ] ** All tests pass:** ` pytest tests/ -v ` succeeds
212+ - [ ] ** All tests pass:** ` uv run python -m pytest ` succeeds
210213- [ ] ** No skipped tests:** Fix or document skipped tests
211214- [ ] ** Coverage maintained:** New code has corresponding tests
212215- [ ] ** Isolation:** Tests don't depend on execution order
@@ -217,7 +220,7 @@ Before committing test changes:
217220- [ ] ** Documentation:** Complex test logic has comments
218221
219222** Integration test checklist:**
220- - [ ] E2E tests pass: ` pytest tests/integration/ -v `
223+ - [ ] E2E tests pass: ` uv run python -m pytest tests/integration/ -v`
221224- [ ] Real environment tested: Not just mocks
222225- [ ] Idempotent: Can run multiple times safely
223226- [ ] Reasonable timeout: Integration tests <30s each
@@ -330,38 +333,39 @@ def test_snapshot_write(tmp_path):
330333** Debugging failing tests:**
331334``` bash
332335# Run with verbose output
333- python3 -m pytest tests/test_config.py -vv
336+ uv run python -m pytest tests/test_config.py -vv
334337
335338# Show print statements
336- python3 -m pytest tests/test_config.py -s
339+ uv run python -m pytest tests/test_config.py -s
337340
338341# Stop on first failure
339- python3 -m pytest tests/ -x
342+ uv run python -m pytest -x
340343
341344# Enter debugger on failure
342- python3 -m pytest tests/ --pdb
345+ uv run python -m pytest --pdb
343346
344347# Show last failed tests
345- python3 -m pytest --lf
348+ uv run python -m pytest --lf
346349```
347350
348351** Common issues:**
349- - ** Import errors:** Run from project root, check PYTHONPATH
352+ - ** Import errors:** Run ` uv sync --extra dev ` first, ensure uv run is used
350353- ** Fixture not found:** Check fixture scope and location
351354- ** Test order dependency:** Tests should be independent, fix test isolation
352355- ** Slow tests:** Mock external calls, use tmp_path, check for real network/subprocess
353356- ** Flaky tests:** Usually timing issues, mock time-dependent operations
357+ - ** VIRTUAL_ENV warning:** Run ` deactivate ` first if another venv is active
354358
355359** Test coverage:**
356360``` bash
357361# Generate coverage report
358- python3 -m pytest tests/ --cov=cli_audit --cov-report=html
362+ uv run python -m pytest --cov=cli_audit --cov-report=html
359363
360364# View report
361365open htmlcov/index.html
362366
363367# Show missing lines
364- python3 -m pytest tests/ --cov=cli_audit --cov-report=term-missing
368+ uv run python -m pytest --cov=cli_audit --cov-report=term-missing
365369```
366370
367371## House rules
0 commit comments