django-testing-docs
django-testing-docs copied to clipboard
feat: Set up comprehensive Python testing infrastructure
Add Python Testing Infrastructure
Summary
This PR sets up a comprehensive Python testing infrastructure for the Django Testing Documentation project, providing developers with a ready-to-use testing environment.
Changes Made
Package Management
-
Added Poetry configuration with
pyproject.toml - Migrated to Poetry from manual dependency management
- Set package-mode to false since this is a documentation project (not a distributable package)
Testing Dependencies
- pytest 7.4.0+ - Main testing framework
- pytest-cov 4.1.0+ - Coverage reporting with HTML, XML, and terminal output
- pytest-mock 3.11.0+ - Enhanced mocking utilities
Testing Configuration
-
Custom pytest markers:
unit,integration,slowfor test categorization - Coverage settings: 80% threshold with comprehensive reporting
-
Test discovery: Configured for
test_*.pyand*_test.pypatterns - Warning filters: Configured to handle common warnings appropriately
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures and test configuration
├── unit/ # Unit tests
│ └── __init__.py
├── integration/ # Integration tests
│ └── __init__.py
└── test_setup_validation.py # Infrastructure validation tests
Shared Test Fixtures
The conftest.py includes comprehensive fixtures for:
-
File system testing:
temp_dir,temp_file,project_root -
Content testing:
sample_rst_content,sample_django_test_code -
Mocking utilities:
mock_sphinx_app,mock_file_system -
Environment management:
clean_environment,configure_test_settings
Development Workflow
-
Run tests:
poetry run pytest -
Run with coverage:
poetry run pytest --cov=tests --cov-report=term-missing -
Run specific markers:
poetry run pytest -m unitorpoetry run pytest -m integration
Validation & Quality Assurance
- 12 validation tests verify the infrastructure works correctly
- 91% coverage achieved on test infrastructure code
- All dependencies installed and verified working
-
Git configuration updated with comprehensive
.gitignore
Testing Instructions
-
Install dependencies:
poetry install -
Run validation tests:
poetry run pytest tests/test_setup_validation.py -v -
Run with coverage:
poetry run pytest --cov=tests --cov-report=term-missing -
Test specific categories:
poetry run pytest -m unit # Unit tests only poetry run pytest -m slow # Slow tests only
Notes
- Poetry lock file is committed for reproducible builds
-
Coverage reports are generated in
htmlcov/directory andcoverage.xml - Test artifacts are properly gitignored
-
Claude Code settings (
.claude/) are excluded from version control - Documentation focus: Configuration optimized for documentation project rather than application package
The testing infrastructure is now ready for developers to write comprehensive tests for any Django testing documentation or examples that may be added to this project.