chophound
chophound copied to clipboard
feat: Set up comprehensive Python testing infrastructure
Set up comprehensive Python testing infrastructure
Summary
This PR establishes a complete testing infrastructure for the ChopHound project, providing developers with a robust foundation for writing and running tests.
Changes Made
Package Management
-
Added Poetry as the package manager with comprehensive
pyproject.tomlconfiguration - Migrated dependencies from implicit imports to explicit Poetry dependency management
- Set up development dependencies for testing tools
Testing Framework
- Installed pytest as the main testing framework with advanced configuration
- Added pytest-cov for comprehensive coverage reporting (HTML, XML, terminal)
- Added pytest-mock for powerful mocking capabilities in tests
-
Configured custom markers (
unit,integration,slow) for test categorization
Project Structure
-
Created testing directories:
tests/,tests/unit/,tests/integration/ -
Added comprehensive fixtures in
tests/conftest.pyincluding:- Temporary directory management
- Sample JSON file creation for testing
- Mock argument helpers
- Environment cleanup utilities
- Created validation tests to ensure infrastructure works correctly
Configuration
- Pytest settings: Strict configuration, coverage thresholds, test discovery patterns
- Coverage configuration: Source mapping, exclusion patterns, reporting formats
- Updated .gitignore: Added testing artifacts, Python build files, IDE files
Testing Commands
Developers can now run tests using:
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run tests with verbose output
poetry run pytest -v
# Run only unit tests
poetry run pytest -m unit
# Run only integration tests
poetry run pytest -m integration
# Skip slow tests
poetry run pytest -m "not slow"
# Generate coverage report
poetry run pytest --cov=. --cov-report=html
Validation
- ✅ All infrastructure tests pass
- ✅ Coverage reporting generates HTML and XML outputs
- ✅ Poetry dependency management works correctly
- ✅ Custom pytest markers function properly
- ✅ Shared fixtures are available across test modules
Dependencies Added
-
pytest ^7.4.0- Main testing framework -
pytest-cov ^4.1.0- Coverage reporting -
pytest-mock ^3.11.1- Mocking utilities -
ijson ^3.2.3- JSON parsing (existing dependency, now managed by Poetry)
Notes for Developers
- The testing infrastructure is ready for immediate use
- Coverage threshold is currently set to 0% to allow gradual adoption
- Shared fixtures in
conftest.pyprovide common testing utilities - Both
tests/unit/andtests/integration/directories are ready for test files - The
poetry.lockfile should be committed to ensure reproducible builds