auto-epp
auto-epp copied to clipboard
Set up comprehensive Python testing infrastructure
Set up Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the auto-epp project, transforming it from a simple Python script into a properly structured, testable Python package.
Key Changes Made
- Package Management: Set up Poetry as the package manager with complete
pyproject.tomlconfiguration - Module Structure: Converted single script to proper Python package (
auto_eppmodule) - Testing Framework: Configured pytest with comprehensive settings including:
- 80% coverage threshold requirement
- HTML and XML coverage reporting
- Custom test markers (
unit,integration,slow) - Strict configuration options
- Testing Dependencies: Added development dependencies:
pytest(main testing framework)pytest-cov(coverage reporting)pytest-mock(mocking utilities)
- Directory Structure: Created organized testing layout:
tests/ ├── __init__.py ├── conftest.py (shared fixtures) ├── unit/ │ └── __init__.py ├── integration/ │ └── __init__.py └── test_setup_validation.py - Shared Fixtures: Comprehensive
conftest.pywith fixtures for:- Temporary directories
- Mock configuration files
- Root/non-root user simulation
- AMD/non-AMD driver mocking
- Battery/charging state simulation
- CPU count mocking
- File operation mocking
Testing Infrastructure Components
Coverage Configuration
- Source code coverage tracking for
auto_eppmodule - 80% minimum coverage threshold
- HTML reports generated in
htmlcov/ - XML reports for CI integration (
coverage.xml) - Exclusion of test files and common non-testable patterns
Test Markers
@pytest.mark.unit- Unit tests@pytest.mark.integration- Integration tests@pytest.mark.slow- Long-running tests
Validation Tests
Created test_setup_validation.py to verify:
- ✅ Pytest functionality
- ✅ Module imports working
- ✅ Fixtures operational
- ✅ Coverage integration
- ✅ All testing dependencies available
How to Run Tests
Install Dependencies
poetry install
Run All Tests
poetry run pytest
Run with Coverage
poetry run pytest --cov=auto_epp --cov-report=html
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" # Exclude slow tests
View Coverage Reports
- Terminal: Coverage summary shown after test run
- HTML: Open
htmlcov/index.htmlin browser - XML:
coverage.xmlfor CI tools
Development Notes
- Poetry Scripts: The main auto-epp script is available as
poetry run auto-epp - Lock File:
poetry.lockensures reproducible dependency installations - Configuration: All testing configuration centralized in
pyproject.toml - Gitignore: Updated to exclude testing artifacts, Python bytecode, and IDE files
Ready for Development
The testing infrastructure is now complete and validated. Developers can:
- Write unit tests in
tests/unit/ - Write integration tests in
tests/integration/ - Use existing fixtures from
conftest.py - Run tests with coverage requirements
- Generate HTML coverage reports for detailed analysis
The codebase is now structured for professional development with proper testing practices in place.
🤖 Generated with Claude Code