-
Notifications
You must be signed in to change notification settings - Fork 271
feat: Set up comprehensive Python testing infrastructure #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Conversation
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
- Add Poetry package manager with pyproject.toml configuration - Install testing dependencies: pytest, pytest-cov, pytest-mock - Create organized test directory structure (tests/, unit/, integration/) - Configure pytest with coverage reporting (80% threshold, HTML/XML output) - Add comprehensive shared fixtures in conftest.py for common testing needs - Support for custom test markers (unit, integration, slow, it) - Update .gitignore with testing-related exclusions - Include validation tests to verify infrastructure functionality Ready-to-use testing environment where developers can immediately start writing tests.
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.
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: