-
Notifications
You must be signed in to change notification settings - Fork 178
Add comprehensive testing infrastructure with Poetry and pytest #646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Set up root-level testing infrastructure for the Infinity monorepo with Poetry package management, pytest framework, and comprehensive coverage reporting. - Create pyproject.toml with Poetry configuration in package-mode=false - Add pytest, pytest-cov, and pytest-mock as test dependencies - Configure pytest with unit, integration, slow, and performance markers - Set up coverage reporting with 80% threshold, HTML and XML outputs - Create tests/ directory structure with unit/ and integration/ subdirectories - Add comprehensive conftest.py with shared fixtures (temp_dir, mock_config, etc.) - Create validation tests to verify infrastructure setup - Add tests/README.md with comprehensive testing documentation - Update .gitignore to exclude .claude/* directory - Configure Poetry script commands for easy test execution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR establishes a comprehensive root-level testing infrastructure for the Infinity monorepo using Poetry and pytest. The changes add a unified testing framework at the repository root to orchestrate tests across all packages, complementing the existing package-level testing setups in libs/infinity_emb and libs/client_infinity. Key additions include a root-level pyproject.toml configured with package-mode = false for monorepo compatibility, pytest configuration with custom markers (unit, integration, slow, performance), comprehensive coverage reporting with 80% threshold, and shared fixtures via conftest.py. The infrastructure includes structured test directories (tests/unit/, tests/integration/) with 19 validation tests to verify proper setup, comprehensive documentation in tests/README.md, and integration with the existing Poetry-based toolchain used throughout the project.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| pyproject.toml | 4/5 | Adds root-level Poetry configuration with pytest setup, custom markers, and coverage reporting for monorepo testing orchestration |
| tests/init.py | 5/5 | Simple package initialization file to make tests directory a proper Python package |
| tests/README.md | 5/5 | Comprehensive testing documentation with usage examples, fixture descriptions, and troubleshooting guide |
| tests/conftest.py | Missing | Shared fixtures and pytest configuration - referenced but not shown in the changeset |
| tests/unit/init.py | 5/5 | Package initialization file for unit tests directory |
| tests/unit/test_infrastructure.py | 4/5 | Validation tests for the new testing infrastructure including fixture, marker, and project structure verification |
| tests/integration/init.py | 5/5 | Package initialization file for integration tests directory |
| tests/integration/test_example.py | 5/5 | Example integration tests demonstrating fixture usage and project structure validation |
Confidence score: 4/5
- This PR is generally safe to merge with some consideration needed for potential conflicts with existing testing infrastructure
- Score reflects well-designed testing infrastructure but potential integration concerns with existing package-level pytest configurations in
libs/infinity_embwhich already has comprehensive testing setup - Pay close attention to
pyproject.tomlfor potential dependency conflicts and ensure the new root-level testing doesn't interfere with existing CI/CD workflows
Sequence Diagram
sequenceDiagram
participant User
participant "Poetry CLI"
participant "pytest"
participant "Coverage"
participant "Test Files"
participant "Fixtures"
User->>+"Poetry CLI": "poetry install"
"Poetry CLI"->>+"Poetry CLI": "Parse pyproject.toml"
"Poetry CLI"->>+"Poetry CLI": "Install test dependencies"
"Poetry CLI"-->>-User: "Dependencies installed"
User->>+"Poetry CLI": "poetry run pytest"
"Poetry CLI"->>+pytest: "Execute with config"
pytest->>+pytest: "Load pyproject.toml config"
pytest->>+pytest: "Discover test files"
pytest->>+"Test Files": "Import test modules"
pytest->>+Fixtures: "Load conftest.py fixtures"
Fixtures-->>-pytest: "Fixtures available"
loop For each test
pytest->>+"Test Files": "Execute test function"
"Test Files"->>+Fixtures: "Request fixture"
Fixtures-->>-"Test Files": "Provide fixture data"
"Test Files"-->>-pytest: "Test result"
end
pytest->>+Coverage: "Collect coverage data"
Coverage->>+Coverage: "Track code execution"
Coverage->>+Coverage: "Generate reports"
Coverage-->>-pytest: "Coverage metrics"
pytest-->>-"Poetry CLI": "Test results & coverage"
"Poetry CLI"-->>-User: "Test summary & coverage report"
7 files reviewed, 1 comment
| [tool.poetry.scripts] | ||
| test = "pytest:main" | ||
| tests = "pytest:main" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Poetry scripts pointing directly to pytest:main may not work as expected. Consider using shell commands like 'pytest' instead of module references
| [tool.poetry.scripts] | |
| test = "pytest:main" | |
| tests = "pytest:main" | |
| [tool.poetry.scripts] | |
| test = "pytest" | |
| tests = "pytest" |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pyproject.toml
Line: 21:23
Comment:
**logic:** Poetry scripts pointing directly to pytest:main may not work as expected. Consider using shell commands like 'pytest' instead of module references
```suggestion
[tool.poetry.scripts]
test = "pytest"
tests = "pytest"
```
How can I resolve this? If you propose a fix, please make it concise.|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #646 +/- ##
==========================================
- Coverage 79.54% 79.45% -0.09%
==========================================
Files 43 43
Lines 3495 3495
==========================================
- Hits 2780 2777 -3
- Misses 715 718 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
do i need to update base branch? |
|
Not sure about this pr, seems more an added burden to maintain. Would prefer to have less flaky ci and GitHub caches (we test all python versions). Thanks for opening. |
|
Sorry, It's hard for me to tell if testing is set up or not when everything's in a subfolder. I looked through your test.yaml and didn't see anything that jumped out as a problem. Seems that you have testing set up and going already. I would have to dig into the actions log to see what's causing the issues. |
About UnitSeeker
Hi! This PR is part of the UnitSeeker project, a human-guided initiative to help Python repositories establish testing infrastructure.
Key points:
Learn more about the project and see the stats on our progress at https://unitseeker.llbbl.com/
Summary
This PR establishes a comprehensive root-level testing infrastructure for the Infinity monorepo using Poetry and pytest. While the individual packages (
libs/infinity_emb,libs/client_infinity, etc.) already have their own testing setups, this adds a unified testing framework at the repository root level to orchestrate tests across all packages.Changes Made
Package Management
pyproject.tomlwith Poetry configurationpackage-mode = falsefor monorepo compatibilitypytest ^8.0.0,pytest-cov ^6.0.0,pytest-mock ^3.14.0poetry.lockfile (committed for reproducibility)Testing Configuration
✅ Configured pytest with comprehensive settings in
pyproject.toml:unit,integration,slow,performance✅ Configured coverage.py with:
libs/Directory Structure
Shared Test Fixtures
Created comprehensive
conftest.pywith fixtures:temp_dir- Temporary directory with auto-cleanuptemp_file- Temporary file with auto-cleanupmock_env_vars- Mock environment variablesmock_config- Mock configuration dictionarysample_data- Sample test data structureproject_root- Project root directory pathchange_test_dir- Change to test directory contextValidation Tests
Additional Files
✅ Created
tests/README.mdwith comprehensive documentation covering:✅ Updated
.gitignoreto include.claude/*directoryRunning Tests
Install Dependencies
Run All Tests
Run with Coverage
Run Only Unit Tests
Run Only Integration Tests
Exclude Slow Tests
poetry run pytest -m "not slow"Run Specific Test Directory
Coverage Reporting
The infrastructure is configured to generate multiple coverage report formats:
htmlcov/- openhtmlcov/index.htmlin browsercoverage.xmlfor CI/CD integrationCoverage threshold is set to 80% by default, configurable in
pyproject.toml.Configuration Choices
Poetry Over UV
libs/infinity_embpackagePackage Mode: False
pyproject.tomlusespackage-mode = falsesince this is a monorepolibs/maintain their own packaging configurationComprehensive Markers
Four test markers are configured:
unit- Fast, isolated component testsintegration- Multi-component integration testsslow- Long-running tests (can be excluded with-m "not slow")performance- Benchmark and performance testsCoverage Configuration
libs/directory (where actual packages live)Next Steps
With this infrastructure in place, developers can:
tests/directory for cross-package functionalityconftest.pyin all testscoverage.xmlTesting the Infrastructure
This PR includes 19 validation tests that verify the infrastructure itself:
Expected output:
Verification Checklist
poetry.lockis tracked in git (not in.gitignore)Questions or Feedback?
Please let me know if you'd like any adjustments to:
I'm happy to make modifications to better fit your workflow and preferences!