adaptive-style-transfer
adaptive-style-transfer copied to clipboard
feat: Set up comprehensive Python testing infrastructure with Poetry
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Python project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and running tests with coverage reporting and organized test structure.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry configuration as the project's package manager - Testing Dependencies: Added pytest, pytest-cov, and pytest-mock as development dependencies
Testing Configuration
-
pytest Settings: Configured pytest with:
- Test discovery patterns for multiple naming conventions
- Coverage reporting with HTML and XML output formats
- Strict markers and configuration options
- Custom markers for test categorization (unit, integration, slow)
- Automatic output formatting and failure handling
-
Coverage Settings: Set up coverage.py with:
- Source directory configuration
- Exclusion patterns for test files, virtual environments, and generated code
- Report formatting options and precision settings
Directory Structure
tests/
├── __init__.py
├── conftest.py
├── test_infrastructure_validation.py
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures (conftest.py)
Created comprehensive pytest fixtures including:
temp_dir: Temporary directory creation and cleanupmock_config: Sample configuration dictionarysample_data: Test data structuresmock_json_file,mock_text_file,mock_python_file: File creation helpersenv_vars: Environment variable managementcapture_logs: Log capture utilitycleanup_test_files: Automatic test file cleanup
Additional Setup
- Updated
.gitignorewith testing artifacts and Claude settings - Created validation tests to ensure the infrastructure works correctly
- All 22 validation tests pass successfully
Running Tests
To run tests, use the following command:
poetry run pytest
Additional pytest options are available:
poetry run pytest -v- Verbose outputpoetry run pytest tests/unit/- Run only unit testspoetry run pytest -m integration- Run only integration testspoetry run pytest --cov-report=html- Generate HTML coverage report
Dependencies Added
- pytest (^8.3.4): Core testing framework
- pytest-cov (^5.0.0): Coverage plugin for pytest
- pytest-mock (^3.14.0): Mocking utilities integrated with pytest
Notes
- Poetry lock file (
poetry.lock) should be committed to version control for reproducible builds - Coverage threshold is currently disabled but can be enabled by adding
--cov-fail-under=80to pytest options - The infrastructure is ready for immediate test development - developers can start writing tests in the appropriate directories