Add comprehensive Python testing infrastructure #167
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "UnitSeeker/add-testing-infrastructure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 StarCoder project, providing a foundation for writing and running tests with minimal friction.
Changes Made
Package Management
requirements.txtto Poetry for modern Python dependency managementrequirements.txtpreserved inpyproject.tomlpytest,pytest-cov, andpytest-mockas development dependenciespoetry.lockfor reproducible builds across environmentsTesting Configuration
pyproject.tomlwith:chat/andfinetune/packages@pytest.mark.unit,@pytest.mark.integration,@pytest.mark.slowDirectory Structure
Shared Test Fixtures
The
tests/conftest.pyfile provides reusable fixtures for common testing scenarios:temp_dir- Temporary directory for file operationstemp_file- Temporary test filemock_config- Mock configuration dictionarymock_tokenizer- Mock HuggingFace tokenizermock_model- Mock model for inference testingsample_text&sample_code_snippet- Sample datamock_dataset- Mock dataset for data pipeline testingmock_training_args- Mock training configurationmock_huggingface_hub- Mock HuggingFace Hub clientreset_environment- Auto-cleanup for environment variablesValidation Tests
Created
test_infrastructure.pywith 27 tests to validate:Development Commands
Two convenient shortcuts for running tests:
Updated .gitignore
Added entries for:
.claude/).vscode/,*.code-workspace)Running Tests
Setup
Using the shortcuts
Notes
Coverage Threshold
The 80% coverage threshold is currently commented out in
pyproject.toml:Uncomment this line when you're ready to enforce minimum coverage requirements.
No Actual Unit Tests
This PR intentionally does not include unit tests for the codebase. The goal is to provide:
Developers can immediately start writing tests without any setup overhead.
Poetry vs pip
Poetry was chosen for:
If you prefer to stick with
requirements.txt, you can extract dependencies:Dependencies
All existing dependencies preserved:
tqdm==4.65.0transformers==4.28.1datasets==2.11.0huggingface-hub==0.13.4accelerate==0.18.0Testing the Infrastructure
The infrastructure has been validated with 27 passing tests:
All features confirmed working:
Next Steps
conftest.pyas building blockstests/unit/, integration tests intests/integration/@pytest.mark.unit,@pytest.mark.integration, or@pytest.mark.slow--cov-fail-under=80when readypyproject.tomlsettings to match your team's preferencesQuestions?
Feel free to ask questions, request changes, or suggest improvements. All feedback is welcome and appreciated!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.