Skip to content

feat: Set up comprehensive Python testing infrastructure#18

Open
llbbl wants to merge 1 commit intoplummm:masterfrom
UnitSeeker:add-testing-infrastructure
Open

feat: Set up comprehensive Python testing infrastructure#18
llbbl wants to merge 1 commit intoplummm:masterfrom
UnitSeeker:add-testing-infrastructure

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 4, 2025

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the SyzScope project, providing a ready-to-use environment for writing and running tests.

Changes Made

  • Package Management: Migrated from requirements.txt to Poetry with complete pyproject.toml configuration
  • Testing Framework: Added pytest with pytest-cov and pytest-mock as development dependencies
  • Test Organization: Created structured testing directories:
    • tests/ - Main testing package
    • tests/unit/ - Unit tests directory
    • tests/integration/ - Integration tests directory
  • Configuration: Comprehensive pytest configuration in pyproject.toml with:
    • 80% test coverage threshold
    • HTML and XML coverage reports
    • Custom test markers: unit, integration, slow
    • Proper test discovery patterns
  • Shared Fixtures: Extensive conftest.py with reusable fixtures for:
    • Temporary directories and files
    • Mock VM instances and kernel objects
    • Mock crash cases and analysis components
    • Environment variable mocking
    • Sample binary and C files for testing
  • Validation: Infrastructure validation tests to ensure setup works correctly
  • Development Tools: Updated .gitignore with appropriate testing exclusions

Running Tests

To run tests after setting up the environment:

# Install dependencies
poetry install

# Run all tests
poetry run test
# or
poetry run tests

# Run with coverage
poetry run pytest --cov=syzscope

# Run specific test types
poetry run pytest -m unit        # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m slow        # Slow tests only

Coverage Reporting

Coverage reports are generated in multiple formats:

  • Terminal output with missing lines
  • HTML report in htmlcov/ directory
  • XML report as coverage.xml

Dependencies

The infrastructure includes testing-specific dependencies:

  • pytest ^7.0 - Main testing framework
  • pytest-cov ^4.0 - Coverage reporting
  • pytest-mock ^3.10 - Mocking utilities

Notes

  • All production dependencies from requirements.txt have been migrated to Poetry format
  • The Poetry configuration allows for both exact version pinning and flexible constraints where appropriate
  • The testing infrastructure is framework-agnostic and can be extended for any testing needs
  • Infrastructure validation tests ensure the setup works correctly across different environments

🤖 Generated with Claude Code

- Add Poetry package manager with pyproject.toml configuration
- Migrate existing dependencies from requirements.txt to Poetry
- Configure pytest with coverage reporting and custom markers (unit, integration, slow)
- Create structured testing directories (tests/unit/, tests/integration/)
- Add comprehensive shared fixtures in conftest.py for common testing scenarios
- Set up .gitignore with testing-related exclusions
- Include validation tests to verify infrastructure setup
- Configure 80% test coverage threshold with HTML/XML reporting

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

Co-Authored-By: Claude <noreply@anthropic.com>
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