feat: Set up comprehensive Python testing infrastructure #70
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.
Set up comprehensive Python testing infrastructure
Summary
This PR establishes a complete testing infrastructure for the Python Functions Programming Exercises project, providing developers with a ready-to-use environment for writing and running tests.
Changes Made
Package Management
pyproject.toml
with Poetry configuration as the package managerpytest
(v7.4.0+) - Main testing frameworkpytest-cov
(v4.1.0+) - Coverage reportingpytest-mock
(v3.11.0+) - Mocking utilitiesTesting Configuration
pyproject.toml
:unit
,integration
,slow
,it
(LearnPack compatibility)Directory Structure
Shared Testing Utilities
tests/conftest.py
:temp_dir
- Temporary directory managementmock_config
- Configuration mockingapp
- Dynamic exercise module loadingmock_print
/mock_input
- Built-in function mockingcapture_stdout
- Output capture utilitiessample_data
- Common test data structuresmock_file_system
- File system mockingenvironment_vars
- Environment variable mockingDevelopment Workflow
.gitignore
with testing exclusions:.coverage
,htmlcov/
,coverage.xml
).pytest_cache/
)poetry.lock
is tracked (not ignored) as per best practicesValidation & Quality
How to Run Tests
Install Dependencies
Run All Tests
Run Specific Test Categories
Run With Coverage
Generate Coverage Reports
poetry run pytest # Generates HTML (htmlcov/) and XML reports
Testing Features
@pytest.mark.it
markersNotes
poetry.lock
is tracked in version control for reproducible buildsValidation
All validation tests pass, confirming: