Skip to content

Commit cb1dbf8

Browse files
author
Really Him
committed
feat: add pytest-testmon
1 parent 4d635e8 commit cb1dbf8

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ venv.bak/
3131
.coverage
3232
.coverage.*
3333
.cache
34+
.testmondata*
3435
nosetests.xml
3536
coverage.xml
3637
*.cover

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ else
1717
VENV_ACTIVATE := $(VENV_DIR)/bin/activate
1818
endif
1919

20-
.PHONY: help venv install install-dev install-prod format lint type-check test test-cov check clean clean-venv clean-cov build build-check version-show version-bump-patch version-bump-minor version-bump-major release-test release release-check release-dry-run gh-release gh-release-draft gh-release-test gh-check-cli release-patch release-minor release-major release-dry-patch release-dry-minor release-dry-major gh-release-dry release-doctor release-safety-check gh-release-safe release-patch-safe release-minor-safe release-major-safe
20+
.PHONY: help venv install install-dev install-prod format lint type-check test test-fast test-fast-clean test-cov check clean clean-venv clean-cov build build-check version-show version-bump-patch version-bump-minor version-bump-major release-test release release-check release-dry-run gh-release gh-release-draft gh-release-test gh-check-cli release-patch release-minor release-major release-dry-patch release-dry-minor release-dry-major gh-release-dry release-doctor release-safety-check gh-release-safe release-patch-safe release-minor-safe release-major-safe
2121

2222
help: ## Show this help message
2323
@echo "Usage: make [target]"
@@ -56,6 +56,13 @@ type-check: install-dev ## Run type checking with mypy
5656
test: install-dev ## Run tests with pytest
5757
$(VENV_DIR)/bin/pytest --no-cov
5858

59+
test-fast: install-dev ## Run targeted tests with pytest-testmon
60+
@mkdir -p .cache
61+
TESTMON_DATAFILE=.cache/testmon.sqlite $(VENV_DIR)/bin/pytest --testmon
62+
63+
test-fast-clean: ## Remove cached testmon data to force a full run
64+
rm -f .cache/testmon.sqlite .cache/testmon.sqlite-shm .cache/testmon.sqlite-wal .testmondata*
65+
5966
test-cov: install-dev ## Run tests with coverage report
6067
# Clean up any existing coverage data
6168
@rm -rf .coverage htmlcov

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,21 @@ CYCLOMATIC COMPLEXITY STATISTICS:
519519
# Run all tests
520520
make test
521521

522+
# Run only tests affected by your recent changes (requires initial baseline run)
523+
make test-fast
524+
525+
# Clear pytest-testmon cache to force a full recalculation
526+
make test-fast-clean
527+
522528
# Run with coverage
523529
make test-coverage
524530

525531
# Run specific test file
526532
pytest tests/unit/test_config.py -v
527533
```
528534

535+
The `make test-fast` target automatically stores its SQLite cache under `.cache/testmon.sqlite` via the `TESTMON_DATAFILE` environment variable so the repository root stays clean. If the cache ever gets out of date (for example after switching branches), run `make test-fast-clean` to remove the `.cache/testmon.sqlite*` files and trigger a fresh baseline on the next `make test-fast`.
536+
529537
### Code Quality
530538

531539
```bash

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies = [
4141
dev = [
4242
"pytest>=7.4.0",
4343
"pytest-cov>=4.1.0",
44+
"pytest-testmon>=2.0.20",
4445
"ruff>=0.1.0",
4546
"black>=23.0.0",
4647
"mypy>=1.7.0",

0 commit comments

Comments
 (0)