feat: Add complete Python testing infrastructure with Poetry #6
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 cs-books repository using Poetry as the package manager and pytest as the testing framework. The setup provides a ready-to-use testing environment where developers can immediately start writing tests for the existing Python scripts.
Changes Made
Package Management
pyproject.tomlwith Poetry as the package managerpytest(^7.4.0) - Main testing frameworkpytest-cov(^4.1.0) - Coverage reportingpytest-mock(^3.11.0) - Mocking utilitiesPyGithubdependency from implicit importsTesting Configuration
test_*.pyand*_test.pyfilesunit,integration, andslowsrc,add_commit_git_push,update_readmeDirectory Structure
Fixtures and Utilities
Created comprehensive fixtures in
conftest.py:temp_dir: Creates temporary directories for testingsample_pdf_list: Provides sample PDF filenamesmock_github_config: Mock GitHub configurationsample_readme_content: Sample README contenttemp_workspace: Creates a temporary workspace with sample filesmock_os_system: Mocks os.system callsmock_github: Mocks GitHub APIcapture_stdout: Captures stdout for testing print statementschange_test_dir: Automatically changes to test directoryDevelopment Commands
Added Poetry script commands for convenience:
poetry run test- Run all testspoetry run tests- Alternative command (both work)Both commands support all standard pytest options.
Additional Updates
.gitignorewith:.pytest_cache/,.coverage,htmlcov/, etc.).claude/*)poetry.lockfor applicationsHow to Use
Install dependencies:
Run tests:
Run specific test markers:
View coverage report:
# After running tests, open the HTML report open htmlcov/index.htmlNotes
src/directory was created to follow Python packaging best practicesNext Steps
update_readme.pyandadd_commit_git_push.py