feat: Add complete Python testing infrastructure with Poetry - #42
Open
llbbl wants to merge 1 commit into
Open
Conversation
- Set up Poetry as package manager with proper Python version constraints - Add pytest, pytest-cov, and pytest-mock as development dependencies - Configure comprehensive testing settings in pyproject.toml - Create organized test directory structure with unit/integration subdirs - Add rich conftest.py with common fixtures for testing - Update .gitignore with testing and development entries - Add validation tests to verify infrastructure setup - Configure Poetry scripts for running tests with both 'test' and 'tests' commands
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 Complete Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the WeReader (微信读书助手) project 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.
Changes Made
Package Management
pyproject.tomlwith Poetry configurationrequirements.txtto Poetrypoetry.lockfor reproducible installationsTesting Dependencies
Added as development dependencies:
pytest ^7.4.0- Main testing frameworkpytest-cov ^4.1.0- Coverage reportingpytest-mock ^3.11.0- Mocking utilitiesTesting Configuration
Comprehensive pytest configuration in
pyproject.toml:unit,integration, andslowtest markersDirectory Structure
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementmock_config- Application configuration mockingmock_cookie- Authentication cookie mockingmock_book_info,mock_chapter_list,mock_bookmark- Domain object mocksmock_requests- HTTP requests mockingmock_qt_app- PySide6 QApplication mockingcreate_test_file- Test file factorymock_logger- Loguru logger mockingDevelopment Commands
Poetry scripts configured for running tests:
All standard pytest options are available (e.g.,
-v,-k, specific test selection).Additional Setup
Running Tests
Install dependencies:
Run all tests:
poetry run testRun specific tests:
View coverage report:
Notes
Next Steps
Developers can now immediately start writing tests for the codebase using the established infrastructure. Suggested areas for initial test coverage:
wereader.py- Core API functionalityclient.py- Command-line interfacecookie.py- Cookie managementmain.py