Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Sep 1, 2025

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.toml configuration
  • Module Structure: Converted single script to proper Python package (auto_epp module)
  • 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.py with 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_epp module
  • 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.html in browser
  • XML: coverage.xml for CI tools

Development Notes

  • Poetry Scripts: The main auto-epp script is available as poetry run auto-epp
  • Lock File: poetry.lock ensures 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:

  1. Write unit tests in tests/unit/
  2. Write integration tests in tests/integration/
  3. Use existing fixtures from conftest.py
  4. Run tests with coverage requirements
  5. 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

- Add Poetry package management with pyproject.toml
- Configure pytest with coverage reporting (80% threshold)
- Create testing directory structure (unit/integration)
- Add shared fixtures in conftest.py for common mocking
- Set up development dependencies (pytest, pytest-cov, pytest-mock)
- Create validation tests to verify infrastructure works
- Update .gitignore with Python and testing artifacts
- Structure code as proper auto_epp Python module

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant