Skip to content

feat: Set up comprehensive Python testing infrastructure#26

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

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

Conversation

@llbbl
Copy link

@llbbl llbbl commented Sep 2, 2025

Set up Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the MCP Pipe project, migrating from a basic requirements.txt setup to a full Poetry-managed development environment with robust testing capabilities.

Changes Made

Package Management

  • Added Poetry configuration (pyproject.toml) with proper metadata and dependencies
  • Migrated all dependencies from requirements.txt to Poetry format
  • Updated Python requirement to ^3.10 (required for mcp-proxy compatibility)
  • Added development dependencies: pytest, pytest-cov, pytest-mock

Testing Configuration

  • Configured pytest with comprehensive settings:
    • Test discovery patterns for different file naming conventions
    • Coverage reporting with 80% threshold requirement
    • HTML and XML coverage report generation
    • Strict configuration and markers
  • Custom test markers: unit, integration, slow for better test organization
  • Coverage configuration with appropriate exclusions and reporting options

Directory Structure

  • Created testing directories:
    • tests/ (main test directory)
    • tests/unit/ (unit tests)
    • tests/integration/ (integration tests)
    • All directories include __init__.py files

Shared Testing Utilities

  • Comprehensive conftest.py with fixtures for:
    • Temporary directories and file creation
    • Mock WebSocket connections and processes
    • Environment variable management
    • Sample server scripts and configurations
    • Calculator test cases and validation data

Development Workflow

  • Poetry scripts: poetry run test and poetry run tests commands
  • Updated .gitignore: Added testing artifacts, build files, IDE settings, and Claude Code configuration
  • Validation tests: Ensure the testing infrastructure works correctly

Testing Instructions

Running Tests

# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov

# 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

# Run validation tests
poetry run pytest tests/test_setup_validation.py -v

Using Poetry Scripts

# Alternative test commands
poetry run test
poetry run tests

Coverage Reporting

  • Terminal: Coverage summary displayed after each test run
  • HTML Report: Generated in htmlcov/ directory
  • XML Report: Generated as coverage.xml for CI/CD integration

Development Notes

  • Python 3.10+ Required: Due to mcp-proxy dependency requirements
  • Poetry Lock File: The poetry.lock file is included in version control for reproducible builds
  • Ready for Development: Infrastructure is set up but no actual unit tests are included - developers can immediately start writing tests using the provided fixtures and structure

Validation

✅ All validation tests pass
✅ Poetry scripts work correctly
✅ Test markers function properly
✅ Coverage reporting generates successfully
✅ Dependencies install without conflicts

🤖 Generated with Claude Code

- Add Poetry package manager with pyproject.toml configuration
- Migrate dependencies from requirements.txt to Poetry
- Install pytest, pytest-cov, and pytest-mock as dev dependencies
- Configure pytest with coverage reporting (80% threshold)
- Create testing directory structure (tests/unit, tests/integration)
- Add comprehensive shared fixtures in conftest.py
- Set up custom test markers (unit, integration, slow)
- Update .gitignore with testing-related entries
- Add validation tests to verify infrastructure setup
- Configure Poetry scripts for running tests

🤖 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