Add comprehensive Python testing infrastructure with Poetry #71
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.
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 adds a comprehensive testing infrastructure to the AI Scientist project, providing a solid foundation for writing and running tests. The setup uses Poetry for dependency management and pytest as the testing framework.
Changes Made
Package Management
pyproject.tomlwith Poetry setuprequirements.txtto Poetry formatTesting Dependencies
Added the following testing tools as development dependencies:
pytest(v8.0.0+) - Main testing frameworkpytest-cov(v6.0.0+) - Coverage reportingpytest-mock(v3.14.0+) - Enhanced mocking utilitiesDirectory Structure
Created organized test directory layout:
Testing Configuration
Configured pytest in
pyproject.tomlwith:test_*.py,*_test.py)@pytest.mark.unit- Unit tests for isolated components@pytest.mark.integration- Integration tests for multiple components@pytest.mark.slow- Tests with longer execution timesShared Fixtures
Created comprehensive shared fixtures in
tests/conftest.py:temp_dir- Temporary directory for test filestemp_file- Temporary file creationmock_config- Mock configuration dictionariessample_data_dir- Sample data directory with test filesmock_env_vars- Environment variable mockingcapture_logs- Log capture for testingreset_environment- Automatic cleanup between testsValidation Tests
Added
tests/test_infrastructure.pywith tests to verify:Configuration Updates
testandtestscommands for convenience.pytest_cache/,.coverage,htmlcov/,coverage.xml) and Claude Code filesRunning Tests
Install Dependencies
Run All Tests
Run with Specific Options
View Coverage Report
After running tests with coverage, open
htmlcov/index.htmlin your browser to see detailed coverage information.Notes
Coverage Threshold
The 80% coverage threshold is currently commented out in the configuration to allow the infrastructure to be validated without existing tests. Once unit tests are written, uncomment line 97 in
pyproject.toml:# fail_under = 80Poetry Lock File
The
poetry.lockfile has been generated and should be committed to ensure reproducible builds across all environments.Next Steps
This PR provides the testing infrastructure only. Developers can now:
tests/unit/tests/integration/conftest.pypoetry run testValidation
All infrastructure validation tests pass successfully:
testandtestscommands operational🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]