Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Jun 25, 2025

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the ICCV 2023 Paper Analysis project using Poetry as the package manager and pytest as the testing framework.

Changes Made

Package Management

  • Poetry Setup: Added pyproject.toml with complete project configuration
  • Dependencies: Migrated existing dependencies (beautifulsoup4, markdown2, prettytable, PyGithub) to Poetry
  • Dev Dependencies: Added pytest, pytest-cov, and pytest-mock as development dependencies

Testing Configuration

  • pytest Configuration:

    • Configured test discovery patterns
    • Added coverage reporting (HTML, XML, terminal)
    • Set up custom markers: unit, integration, slow
    • Enabled strict markers and verbose output
  • Coverage Settings:

    • Source directory: code/
    • Excluded: tests, cache, virtual environments
    • Reports: HTML in htmlcov/, XML as coverage.xml
    • Threshold: Currently 0% (should be changed to 80% when adding real tests)

Directory Structure

tests/
├── __init__.py
├── conftest.py          # Shared fixtures
├── unit/
│   └── __init__.py
├── integration/
│   └── __init__.py
└── test_infrastructure_validation.py

Testing Fixtures (conftest.py)

  • temp_dir: Creates temporary directories for test files
  • sample_markdown_content: Sample markdown for testing parsers
  • sample_json_data: Sample JSON structure for testing
  • mock_config: Mocked configuration values
  • mock_github_repo: Mocked GitHub repository
  • create_test_file: Factory fixture for creating test files
  • Additional fixtures for HTML content, BeautifulSoup mocking, and logging

Other Updates

  • .gitignore: Added entries for:
    • .claude/* - Claude-specific files
    • Testing artifacts (.pytest_cache/, htmlcov/, coverage.xml, .coverage)
    • Note: poetry.lock is NOT ignored (should be committed)

How to Use

  1. Install dependencies:

    poetry install
  2. Run tests:

    poetry run test   # or
    poetry run tests  # both commands work
  3. Run specific test markers:

    poetry run pytest -m unit        # Run only unit tests
    poetry run pytest -m integration # Run only integration tests
    poetry run pytest -m "not slow"  # Skip slow tests
  4. View coverage report:

    • Terminal: Automatically shown after test run
    • HTML: Open htmlcov/index.html in a browser
    • XML: Available at coverage.xml for CI integration

Next Steps

  1. Adjust Coverage Threshold: Change from 0% to 80% in pyproject.toml when adding real tests
  2. Write Unit Tests: Add unit tests for the markdown parser in tests/unit/
  3. Write Integration Tests: Add integration tests for the full workflow in tests/integration/
  4. CI Integration: Use the XML coverage report for CI/CD pipelines

Validation

The infrastructure has been validated with 12 passing tests that verify:

  • pytest is properly installed and configured
  • All fixtures are accessible and working
  • Test markers are functional
  • Coverage reporting generates correctly
  • Both poetry run test and poetry run tests commands work

The project is now ready for test-driven development!

- Add Poetry package manager with pyproject.toml configuration
- Configure pytest with coverage reporting and custom markers
- Create testing directory structure with unit/integration subdirectories
- Add comprehensive pytest fixtures in conftest.py
- Update .gitignore with testing and Claude-specific entries
- Add validation tests to verify infrastructure functionality
- Configure Poetry scripts for 'test' and 'tests' commands
- Set coverage threshold to 0% temporarily (change to 80% when adding real tests)
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