localrf
localrf copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
Add Python Testing Infrastructure
This PR sets up a complete testing infrastructure for the LocalTensorF Python project using Poetry as the package manager and pytest as the testing framework.
Summary of Changes
Package Management
- Created
pyproject.tomlwith Poetry configuration - Set up the project as
localtensorfwith proper metadata - Configured Poetry to manage dependencies and virtual environments
Testing Dependencies
Added the following development dependencies:
- pytest (v7.4.0+): Main testing framework
- pytest-cov (v4.1.0+): Coverage reporting plugin
- pytest-mock (v3.11.0+): Mocking utilities for tests
Testing Configuration
Configured comprehensive testing settings in pyproject.toml:
- Test discovery patterns for
test_*.pyand*_test.pyfiles - Coverage reporting with 80% threshold requirement
- Multiple coverage output formats (terminal, HTML, XML)
- Custom test markers:
unit,integration, andslow - Proper source inclusion and exclusion patterns for coverage
Directory Structure
Created a well-organized testing structure:
tests/
├── __init__.py
├── conftest.py # Shared pytest fixtures
├── test_setup_validation.py # Validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures (conftest.py)
Added comprehensive fixtures for common testing needs:
temp_dirandtemp_file: Temporary file system resourcesmock_config: Mock configuration objectssample_data: Sample data for testingmock_modelandmock_dataset: ML-specific mocksjson_fileandconfig_file: Temporary config filesmock_logger: Logging mock utilitiesmock_file_system: File system operation mockscapture_logs: Log capturing for assertionsbenchmark_timer: Simple performance timing- And more...
Additional Setup
- Updated
.gitignorewith testing artifacts (.pytest_cache/,htmlcov/, etc.) - Added Claude-specific entries to
.gitignore(.claude/*) - Created validation tests to ensure the infrastructure works correctly
How to Run Tests
Install Dependencies
poetry install
Run All Tests
poetry run pytest
Run Tests with Coverage
poetry run pytest --cov
Run Specific Test Categories
# Unit tests only
poetry run pytest -m unit
# Integration tests only
poetry run pytest -m integration
# Exclude slow tests
poetry run pytest -m "not slow"
Generate Coverage Reports
Coverage reports are automatically generated in multiple formats:
- Terminal output with missing lines
- HTML report in
htmlcov/directory - XML report as
coverage.xml
Notes
- The project uses Poetry for dependency management, ensuring consistent environments
- Coverage threshold is set to 80% to maintain high code quality
- All test infrastructure has been validated with passing tests
- The setup is ready for developers to immediately start writing tests
- No actual unit tests for the codebase were written - only infrastructure setup