feat: Set up comprehensive Python testing infrastructure#3
Open
llbbl wants to merge 1 commit intocryscan:masterfrom
Open
feat: Set up comprehensive Python testing infrastructure#3llbbl wants to merge 1 commit intocryscan:masterfrom
llbbl wants to merge 1 commit intocryscan:masterfrom
Conversation
- Configure Poetry as package manager with pyproject.toml - Add pytest, pytest-cov, and pytest-mock as dev dependencies - Set up pytest configuration with 80% coverage threshold - Create tests/ directory structure with unit/integration subdirs - Add comprehensive shared fixtures in conftest.py - Configure coverage reporting (HTML, XML, terminal) - Set up custom test markers (unit, integration, slow) - Update .gitignore with testing and build artifacts - Add Poetry scripts for running tests (test/tests commands) - Create validation tests to verify infrastructure works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Python project, providing a ready-to-use environment for developers to write and run tests efficiently.
Changes Made
Package Management
pyproject.tomlconfigurationrequirements.txtto Poetry format^2.0.0for better compatibilityTesting Framework Setup
pytest(^7.4.0) - Main testing frameworkpytest-cov(^4.1.0) - Coverage reportingpytest-mock(^3.11.1) - Mocking utilitiespyproject.toml:unit,integration,slowDirectory Structure
Shared Testing Utilities
conftest.pywith comprehensive fixtures:temp_dir- Temporary directory for test filestemp_file- Temporary file managementmock_config- Mock configuration objectsmock_torch_device- GPU-free torch device mockingmock_model- RWKV model mockingmock_tokenizer- Tokenizer mockingmock_flask_app- Flask application mockingmock_requests- HTTP requests mockingreset_environment- Environment variable isolationcapture_logs- Log capture utilitiesDevelopment Commands
poetry run test- Run all testspoetry run tests- Alternative commandConfiguration Files
.gitignorewith testing-related entries:.pytest_cache/,.coverage,htmlcov/)build/,dist/,*.egg-info/).claude/*)Testing Infrastructure Features
Coverage Reporting
htmlcov/), XML (coverage.xml)Custom Test Markers
@pytest.mark.unit- For unit tests@pytest.mark.integration- For integration tests@pytest.mark.slow- For performance/slow testsValidation Tests
test_setup_validation.py)How to Run Tests
Install Dependencies
Run All Tests
Run Specific Test Types
Run with Coverage
poetry run pytest --cov-report=html # Then open htmlcov/index.htmlRun Validation Tests
Validation Results
✅ All validation tests pass (10/10)
✅ Both test commands work (
testandtests)✅ Coverage reporting generates HTML and XML reports
✅ Custom markers function properly
✅ Shared fixtures available across test suite
✅ Environment isolation working
Next Steps
Developers can now:
tests/unit/tests/integration/conftest.pypoetry run testThe testing infrastructure is now ready for immediate use!