OnePose
OnePose copied to clipboard
feat: Add complete Python testing infrastructure with Poetry
Add Complete Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the OnePose Python project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Setup: Created
pyproject.tomlwith Poetry configuration - Dependencies: Migrated existing dependencies from
requirements.txt - Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
Testing Configuration
- pytest Configuration: Configured in
pyproject.tomlwith:- Test discovery patterns (
test_*.py,*_test.py) - Coverage settings with 80% threshold
- HTML and XML coverage report generation
- Custom test markers:
unit,integration,slow - Strict mode enabled for better error detection
- Test discovery patterns (
Project Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py
├── test_basic_validation.py
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures (conftest.py)
temp_dir: Temporary directory for test filestemp_file: Temporary file creationmock_config: Mock configuration dictionarysample_yaml_config: YAML config file generationsample_image_data: Sample image metadatasample_annotation_data: Sample annotation datamock_model_checkpoint: Mock checkpoint fileenvironment_setup: Environment variable setupcleanup_wandb: Disable wandb during testsmock_dataset_structure: Mock dataset directory structurecapture_logs: Log capture fixture
Additional Setup
- Updated
.gitignorewith:- Testing artifacts (
.pytest_cache/,.coverage,htmlcov/, etc.) - Claude settings (
.claude/*) - Python build artifacts and virtual environments
- Testing artifacts (
- Created validation tests to verify the infrastructure works
How to Use
Install Dependencies
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Install project dependencies
poetry install
# Install only development dependencies
poetry install --only dev
Run Tests
# Run all tests with coverage
poetry run pytest
# Run specific test markers
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m "not slow"
# Run with verbose output
poetry run pytest -v
# Generate coverage report
poetry run pytest --cov-report=html
Writing Tests
- Place unit tests in
tests/unit/ - Place integration tests in
tests/integration/ - Use fixtures from
conftest.pyfor common test needs - Mark tests appropriately:
@pytest.mark.unit def test_something(): pass @pytest.mark.integration def test_integration(): pass @pytest.mark.slow def test_slow_operation(): pass
Notes
- The testing infrastructure is set up but doesn't include actual unit tests for the codebase
- Some project dependencies may have compatibility issues on certain platforms
- Poetry lock file will be generated on first install
- Coverage threshold is set to 80% but can be adjusted in
pyproject.toml
Next Steps
- Install dependencies with
poetry install - Run validation tests to ensure setup works
- Start writing unit tests for existing code
- Set up CI/CD to run tests automatically