llama3.np
llama3.np copied to clipboard
feat: Add comprehensive Python testing infrastructure
Add Comprehensive Python Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the Python project, providing a foundation for writing and running tests with proper tooling and configuration.
Changes Made
๐ฆ Package Management
- Poetry Setup: Created
pyproject.tomlwith Poetry configuration as the package manager - Dependency Migration: Migrated existing
numpydependency fromrequirements.txt - Poetry Lock: Added
poetry.lockto.gitignoreto avoid version conflicts
๐งช Testing Dependencies
Added as development dependencies:
pytest(^7.4.0) - Main testing frameworkpytest-cov(^4.1.0) - Coverage reporting pluginpytest-mock(^3.11.0) - Mocking utilities
โ๏ธ Configuration
pytest Configuration (pyproject.toml)
- Test discovery patterns for
test_*.pyand*_test.pyfiles - Strict markers and configuration enforcement
- Coverage reporting with HTML and XML output
- Custom markers:
unit,integration,slow
Coverage Configuration
- Source includes all project files
- Excludes test files, cache directories, virtual environments
- Configured exclusion patterns for non-testable code
๐ Directory Structure
tests/
โโโ __init__.py
โโโ conftest.py # Shared fixtures and configuration
โโโ test_setup_validation.py # Validation tests
โโโ unit/
โ โโโ __init__.py
โโโ integration/
โโโ __init__.py
๐ง Shared Fixtures (conftest.py)
temp_dir: Temporary directory managementmock_config: Configuration dictionary for testingsample_text_data: Sample text data for testingmock_model_weights: Mock file creationenv_var_backup: Environment variable isolationreset_random_seeds: Reproducible test runscapture_logs: Log message capture
๐ Additional Updates
- Updated
.gitignorewith testing artifacts and Claude settings - Created validation tests to verify the infrastructure works
Usage Instructions
Install Dependencies
poetry install
Run Tests
# Run all tests
poetry run test
# Alternative command (both work)
poetry run tests
# Run with specific markers
poetry run pytest -m unit
poetry run pytest -m integration
poetry run pytest -m "not slow"
# Run without coverage
poetry run pytest --no-cov
# Run specific test file
poetry run pytest tests/test_setup_validation.py
Coverage Reports
- Terminal: Coverage summary shown after each test run
- HTML Report: Generated in
htmlcov/directory - XML Report: Generated as
coverage.xmlfor CI integration
Notes
- The infrastructure is set up but does not include actual unit tests for the codebase
- Coverage threshold is currently not enforced (removed
--cov-fail-under=80from default options) - All pytest standard options remain available for use
- The validation test suite confirms all components are working correctly
Validation Results
All validation tests pass successfully:
- โ pytest installation verified
- โ Project structure validated
- โ Fixtures working correctly
- โ Custom markers registered
- โ Coverage configuration functional
- โ
Both
testandtestscommands operational