feat: Set up Python testing infrastructure with Poetry and pytest#65
Open
llbbl wants to merge 1 commit intoatulkum:masterfrom
Open
feat: Set up Python testing infrastructure with Poetry and pytest#65llbbl wants to merge 1 commit intoatulkum:masterfrom
llbbl wants to merge 1 commit intoatulkum:masterfrom
Conversation
- Initialize Poetry package manager with pyproject.toml configuration - Add pytest, pytest-cov, and pytest-mock as dev dependencies - Configure pytest with custom markers (unit, integration, slow) - Set up coverage reporting with HTML and XML output - Create test directory structure with shared fixtures in conftest.py - Add validation tests to verify the testing setup works correctly - Update .gitignore with testing and development artifacts - Configure test commands accessible via `poetry run test` or `poetry run tests`
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.
Add Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the pointer-summarizer project using Poetry as the package manager and pytest as the testing framework. The setup provides a solid foundation for writing and running tests with proper coverage reporting and organization.
Changes Made
Package Management
pyproject.tomlwith Poetry package management configurationpytest(^7.4.0) - Core testing frameworkpytest-cov(^4.1.0) - Coverage reporting pluginpytest-mock(^3.11.0) - Mocking utilitiesTesting Configuration
pytest Settings:
test_*.pyand*_test.pyfilesunit,integration, andslowCoverage Settings:
data_utilandtraining_ptr_gendata_util/data.py) temporarilyDirectory Structure
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementmock_config- Mock configuration dictionarysample_vocab- Mock vocabulary objectsample_batch_data- Sample batch data for model testingdevice- PyTorch device detectionreset_random_seeds- Reproducible test runsmock_data_path,mock_model_path,mock_log_path- Mock directory structuresDevelopment Workflow
.gitignorewith testing artifacts, virtual environments, and IDE filespoetry.lockis NOT gitignored to ensure reproducible buildsHow to Use
Installation
Running Tests
Both commands work identically:
Test Options
All standard pytest options are available:
Coverage Reports
After running tests, coverage reports are available:
htmlcov/index.htmlcoverage.xmlNotes
Python Version: The project appears to have some Python 2 syntax (e.g.,
data_util/data.py). These files are temporarily excluded from coverage until migrated.pyrouge Dependency: The original
pyrougepackage is not available on PyPI. It needs to be installed separately following its specific installation instructions.Coverage Threshold: Currently set to 0% to allow the infrastructure setup to complete. This should be increased (e.g., to 80%) as actual tests are added.
Validation Tests: The PR includes validation tests that verify the testing infrastructure is working correctly. These are not unit tests for the actual codebase.
Next Steps
With this testing infrastructure in place, developers can now: