PyTorch-progressive_growing_of_gans
PyTorch-progressive_growing_of_gans copied to clipboard
feat: Set up Python testing infrastructure with Poetry and pytest
Set up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the BEGAN PyTorch project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith Poetry setup as the default package manager - Dependencies: Added testing dependencies as development dependencies:
pytest(^7.4.0) - Main testing frameworkpytest-cov(^4.1.0) - Coverage reportingpytest-mock(^3.11.0) - Mocking utilities
Testing Configuration
-
pytest Settings: Configured in
pyproject.tomlwith:- Test discovery patterns for flexible test file naming
- Coverage reporting with HTML and XML output formats
- Custom test markers:
unit,integration,slow - Strict configuration for better error detection
-
Coverage Settings:
- Source directories:
models/andutils/ - Excluded: test files, cache directories, virtual environments
- Coverage threshold set to 0% (to be increased as tests are added)
- Source directories:
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared pytest fixtures
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Test Fixtures (conftest.py)
temp_dir: Temporary directory for test filesmock_config: Mock configuration dictionarysample_data: Mock tensor data for testingmock_model_path: Path utilities for model filesreset_modules: Module cleanup between testscapture_stdout: Output capturing for testing print statementstest_data_dir: Session-scoped test data directory
Development Workflow
- Scripts: Added Poetry scripts for running tests
poetry run test- Run all testspoetry run tests- Alternative command (both work)
Additional Updates
.gitignore: Updated with comprehensive patterns for:- Testing artifacts (
.pytest_cache/,.coverage,htmlcov/, etc.) - Claude settings (
.claude/*) - Virtual environments and build artifacts
- IDE files and OS-specific files
- Testing artifacts (
How to Use
-
Install dependencies:
poetry install -
Run tests:
# Run all tests poetry run test # Run with specific options poetry run pytest -v # Run only unit tests poetry run pytest -m unit # Run with coverage report poetry run pytest --cov -
View coverage reports:
- Terminal: Coverage summary is shown after test runs
- HTML: Open
htmlcov/index.htmlin a browser - XML: Available at
coverage.xmlfor CI integration
Notes
- The project's existing code has dependencies on
torchandtensorflowwhich are not included in this testing setup - Coverage threshold is currently set to 0% to allow the infrastructure to be established first
- The validation tests confirm that the testing infrastructure is working correctly
- Poetry lock file (
poetry.lock) is included and should be committed to ensure reproducible builds
Next Steps
- Add project dependencies (torch, tensorflow, etc.) to
pyproject.toml - Write unit tests for existing modules
- Gradually increase coverage threshold as tests are added
- Configure CI/CD to run tests automatically