feat: Set up comprehensive Python testing infrastructure with Poetry#46
feat: Set up comprehensive Python testing infrastructure with Poetry#46llbbl wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
- Migrated from setup.py to Poetry-based dependency management - Added pytest, pytest-cov, and pytest-mock as dev dependencies - Configured pytest with coverage reporting and custom markers - Created testing directory structure with unit/integration separation - Added shared fixtures in conftest.py for common test scenarios - Updated .gitignore with testing and Claude-specific entries - Added validation tests to verify infrastructure setup
|
Hi @llbbl! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the hiera-transformer project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and maintaining tests with proper coverage reporting and organization.
Changes Made
Package Management
pyproject.tomlwith all dependencies fromsetup.pyTesting Configuration
Pytest configuration in
pyproject.toml:test_*.pyand*_test.pyfilesunit,integration, andslowCoverage configuration:
hierapackageDirectory Structure
Shared Fixtures (conftest.py)
temp_dir: Temporary directory for test filesmock_model_config: Mock Hiera model configurationdevice: PyTorch device (CPU/CUDA) detectionsample_image_tensor: Sample image tensor for testingmock_checkpoint_path: Mock checkpoint file creationreset_random_state: Ensures reproducible testscapture_stdout: Capture print statementsmock_timm_model: Mock timm model creationDevelopment Commands
poetry run test- Run all testspoetry run tests- Alternative command (both work)Additional Setup
.gitignorewith:How to Use
Installation
Running Tests
Writing New Tests
tests/unit/ortests/integration/@pytest.mark.unit,@pytest.mark.integration,@pytest.mark.slow)conftest.pytests/unit/test_example.pyNotes
pyproject.tomlTesting the Setup
The PR includes validation tests that verify:
Run
poetry run testafter installation to verify everything works correctly.