pytools
pytools copied to clipboard
feat: Add complete testing infrastructure with Poetry
Add Complete Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the pytools project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Setup: Created
pyproject.tomlwith complete Poetry configuration - Dependency Migration: Migrated all dependencies from
requirements.txtto Poetry - Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
Testing Configuration
-
Pytest Configuration:
- Custom markers for unit, integration, and slow tests
- Coverage reporting with HTML and XML output
- Strict mode enabled for better test quality
- Test discovery patterns configured
-
Coverage Settings:
- Source set to pytools package
- Exclusions for test files and common patterns
- HTML and XML report generation
Project Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures and configuration
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures (conftest.py)
temp_dir- Temporary directory managementtemp_file- Temporary file creationmock_config- Mock configuration datamock_json_file- JSON file fixturesmock_response- HTTP response mockingmock_qt_app- PyQt5 application mockingsample_image_path- Image file fixturesmock_email_server- Email server mockingenv_vars- Environment variable management
Commands Available
poetry run test- Run all testspoetry run tests- Alternative command (both work)- All standard pytest options are available
Testing the Setup
-
Install dependencies:
poetry install -
Run validation tests:
poetry run test tests/test_setup_validation.py -
Run all tests with coverage:
poetry run test
Notes
- Coverage threshold is currently set to 0% due to the large existing codebase
- Some dependencies (like PyQt5) may have platform-specific installation issues
- The infrastructure is ready for developers to start writing unit and integration tests
- Both
poetry.lockfile should be committed to ensure reproducible builds
Next Steps
- Developers can now write tests in the
tests/unitandtests/integrationdirectories - Use the provided fixtures in
conftest.pyfor common testing needs - Mark tests appropriately with
@pytest.mark.unit,@pytest.mark.integration, or@pytest.mark.slow - Gradually increase coverage threshold as more tests are added