sublime-filterlines
sublime-filterlines copied to clipboard
feat: Add comprehensive Python testing infrastructure
Add Python Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the Filter Lines Sublime Text plugin, enabling developers to write and run unit and integration tests with proper mocking of Sublime Text APIs.
Changes Made
Package Management
- Added
pyproject.tomlwith Poetry configuration - Configured Poetry with
package-mode = falsefor Sublime Text plugin compatibility - Added testing dependencies:
pytest,pytest-cov, andpytest-mock
Testing Configuration
- Configured pytest with:
- Coverage reporting with 80% threshold
- HTML and XML coverage report generation
- Custom test markers:
unit,integration,slow - Strict mode for better error detection
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py # Infrastructure validation
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Test Fixtures
Created comprehensive fixtures in conftest.py:
mock_sublime- Mocked sublime module with constants and Region classmock_sublime_plugin- Mocked sublime_plugin modulemock_view- Full mock of Sublime Text view objectmock_window- Mock of Sublime Text window objecttemp_dir/temp_file- Temporary file handlingsample_text_lines- Sample data for testingsample_config- Sample configuration settings
Additional Files
- Updated
.gitignorewith testing, IDE, and build artifacts - Added
TESTING.mdwith comprehensive testing guidelines - Created validation tests to verify the infrastructure works correctly
How to Use
-
Install dependencies:
poetry install --no-root -
Run tests:
# Run all tests poetry run pytest # Run with verbose output poetry run pytest -v # Run only unit tests poetry run pytest -m unit -
View coverage:
# Terminal report poetry run pytest --cov-report=term # HTML report poetry run pytest --cov-report=html open htmlcov/index.html
Notes
- The infrastructure is ready for developers to start writing tests
- All 15 validation tests pass successfully
- Coverage is currently low (13.25%) as no actual unit tests have been written yet
- The mocking infrastructure properly handles Sublime Text's API dependencies
- Tests can be marked as
unit,integration, orslowfor selective execution
Next Steps
Developers can now:
- Write unit tests in
tests/unit/ - Write integration tests in
tests/integration/ - Use the provided fixtures to mock Sublime Text APIs
- Achieve the 80% coverage threshold by testing the plugin functionality