feat: Set up comprehensive Python testing infrastructure
Set up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the card image checking project, providing developers with a ready-to-use testing environment.
Key Changes Made
-
Package Management: Migrated from
requirements.txtto Poetry withpyproject.toml- Converted all existing dependencies to Poetry format
- Separated development dependencies (testing tools) from production dependencies
- Fixed Python version compatibility issues
-
Testing Framework Setup:
- Added
pytestas the primary testing framework - Integrated
pytest-covfor coverage reporting with 80% threshold - Added
pytest-mockfor enhanced mocking capabilities
- Added
-
Testing Configuration (
pyproject.toml):- Configured test discovery patterns and output formatting
- Set up coverage reporting (HTML, XML, and terminal)
- Added custom markers:
unit,integration,slow - Enabled strict configuration and warnings filtering
-
Directory Structure:
tests/ ├── __init__.py ├── conftest.py # Shared fixtures ├── test_infrastructure.py # Validation tests ├── unit/ │ └── __init__.py └── integration/ └── __init__.py -
Comprehensive Fixtures (
tests/conftest.py):temp_dir: Temporary directory for test filessample_image_path: Mock image file for testingmock_config: Mock configuration objectmock_cv2,mock_keyboard,mock_pillow_image: Module mockssample_card_data: Test data for card objectscapture_stdout,mock_file_system: Testing utilities
-
Updated .gitignore:
- Added testing artifacts (
.pytest_cache/,.coverage,htmlcov/) - Included virtual environment and IDE files
- Added OS-specific and Claude Code entries
- Added testing artifacts (
Testing Commands
After this PR is merged, developers can run tests using:
# Install dependencies
poetry install
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov
# Run specific test types
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m "not slow" # Skip slow tests
# Run specific test files
poetry run pytest tests/unit/
poetry run pytest tests/integration/
Infrastructure Validation
The PR includes comprehensive validation tests (tests/test_infrastructure.py) that verify:
- All testing dependencies are properly installed
- Project structure is correctly set up
- Fixtures are working as expected
- Custom pytest markers are available
- Poetry commands function properly
Notes
- Python Version: Set to
>=3.8,<3.12for compatibility with existing dependencies - Build Tools: Removed PyInstaller from main dependencies to avoid version conflicts (can be added back as dev dependency if needed for building executables)
- Coverage: HTML coverage reports are generated in
htmlcov/directory - Lock File:
poetry.lockis included to ensure consistent dependency versions
Next Steps
With this infrastructure in place, developers can immediately start writing tests for the existing codebase. The shared fixtures provide everything needed to test image processing, configuration management, and user interactions.