Skip to content

feat: Set up comprehensive Python testing infrastructure#18

Open
llbbl wants to merge 1 commit intovision4robotics:mainfrom
UnitSeeker:add-testing-infrastructure
Open

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

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 2, 2025

Set Up Comprehensive Python Testing Infrastructure

Summary

This PR establishes a complete testing infrastructure for the PySOT (Python Single Object Tracking) project, providing developers with a ready-to-use testing environment.

Changes Made

  • Package Management: Set up Poetry as the package manager with comprehensive pyproject.toml configuration
  • Dependency Migration: Migrated all dependencies from requirement.txt to Poetry format
  • Testing Framework: Configured pytest with extensive options and custom markers
  • Coverage Reporting: Set up pytest-cov with 80% coverage threshold and HTML/XML output
  • Directory Structure: Created proper testing directory structure with tests/, unit/, and integration/ subdirectories
  • Shared Fixtures: Added comprehensive fixtures in conftest.py for common testing scenarios
  • Validation Tests: Created infrastructure validation tests to ensure proper setup
  • Development Scripts: Added Poetry scripts for easy test execution (poetry run test/poetry run tests)
  • Git Configuration: Updated .gitignore with testing-related entries and development files

Testing Infrastructure Components

Dependencies Added

  • pytest - Main testing framework
  • pytest-cov - Coverage reporting
  • pytest-mock - Mocking utilities

Configuration Features

  • Custom Markers: unit, integration, slow for test categorization
  • Coverage Settings: 80% threshold with HTML and XML reporting
  • Test Discovery: Automatic discovery of test files and functions
  • Strict Configuration: Enforces proper marker usage and configuration

Shared Fixtures Available

  • temp_dir - Temporary directory for file operations
  • mock_config - Mock configuration objects
  • sample_image - Sample image data for vision tests
  • sample_bbox - Sample bounding box coordinates
  • mock_tracker, mock_model, mock_logger - Mock objects for testing
  • sample_dataset_config - Mock dataset configuration
  • mock_video_data - Mock video sequence data

Running Tests

After this PR is merged, developers can immediately start using the testing infrastructure:

# Install dependencies
poetry install

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

# 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

# Run with coverage
poetry run pytest --cov=pysot --cov=toolkit

# Generate coverage reports
poetry run pytest  # HTML report in htmlcov/, XML in coverage.xml

Validation

The setup includes comprehensive validation tests that verify:

  • ✅ pytest functionality and marker configuration
  • ✅ Shared fixtures availability and functionality
  • ✅ Project structure and package imports
  • ✅ Coverage configuration
  • ✅ Mock dependencies and testing utilities

All validation tests pass, confirming the infrastructure is ready for use.

Notes

  • The original requirement.txt file has been migrated to Poetry format in pyproject.toml
  • Poetry lock file is included and should be committed (not in .gitignore)
  • Coverage threshold is set to 80% - this can be adjusted in pyproject.toml if needed
  • The infrastructure supports both pysot and toolkit packages with appropriate coverage configuration

🤖 Generated with Claude Code

- Add Poetry package manager with pyproject.toml configuration
- Migrate dependencies from requirement.txt to Poetry
- Configure pytest with coverage reporting (80% threshold)
- Set up testing directory structure (tests/, unit/, integration/)
- Add comprehensive shared fixtures in conftest.py
- Create custom pytest markers (unit, integration, slow)
- Configure coverage reporting (HTML/XML output)
- Add .gitignore with testing and development entries
- Create validation tests to verify infrastructure setup
- Set up Poetry scripts for running tests (test/tests commands)

🤖 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