beso icon indicating copy to clipboard operation
beso copied to clipboard

feat: Set up comprehensive Python testing infrastructure

Open llbbl opened this issue 3 months ago • 0 comments

Set up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the BESO project, providing developers with a ready-to-use testing environment.

Changes Made

  • Poetry Package Management: Set up Poetry as the package manager with pyproject.toml configuration
  • Testing Dependencies: Added essential testing packages:
    • pytest (main testing framework)
    • pytest-cov (coverage reporting)
    • pytest-mock (mocking utilities)
  • Directory Structure: Created organized testing directories:
    • tests/ (root test directory)
    • tests/unit/ (unit tests)
    • tests/integration/ (integration tests)
    • All with proper __init__.py files
  • Testing Configuration: Comprehensive pytest configuration in pyproject.toml:
    • Test discovery patterns
    • Coverage reporting (80% threshold, HTML/XML reports)
    • Custom markers (unit, integration, slow)
    • Strict testing options
  • Shared Fixtures: Rich conftest.py with common fixtures:
    • Temporary directories
    • Mock configurations
    • Sample data (observations, actions, trajectories)
    • PyBullet mocking for environment testing
  • Validation Tests: Comprehensive tests to verify the infrastructure works
  • Updated .gitignore: Added testing-related entries and Claude Code settings

How to Run Tests

# Install dependencies
poetry install

# Run all tests
poetry run pytest

# Run with verbose output
poetry run pytest -v

# Run only unit tests
poetry run pytest -m "unit"

# Run only integration tests  
poetry run pytest -m "integration"

# Run tests excluding slow ones
poetry run pytest -m "not slow"

# Generate coverage report
poetry run pytest --cov=beso --cov-report=html

Coverage Reporting

  • HTML Report: Generated in htmlcov/ directory
  • XML Report: Generated as coverage.xml
  • Terminal Report: Shows missing lines
  • Threshold: Set to 80% coverage requirement

Next Steps

Developers can now:

  1. Write unit tests in tests/unit/
  2. Write integration tests in tests/integration/
  3. Use shared fixtures from conftest.py
  4. Run tests with coverage reporting
  5. Use custom markers to categorize and filter tests

The infrastructure is fully validated and ready for immediate use.

🤖 Generated with Claude Code

llbbl avatar Sep 03 '25 14:09 llbbl