KiteSublime
KiteSublime copied to clipboard
feat: Set up comprehensive Python testing infrastructure
Set up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the KiteSublime project, providing developers with a ready-to-use testing environment that includes all necessary tooling and configuration.
Changes Made
Package Management & Dependencies
- Poetry Setup: Added
pyproject.tomlwith Poetry configuration as the package manager - Testing Dependencies: Added
pytest,pytest-cov, andpytest-mockas development dependencies - Version Management: Configured Python 3.7+ compatibility
Testing Configuration
- pytest Configuration: Comprehensive pytest setup in
pyproject.tomlwith:- Test discovery patterns for various naming conventions
- Coverage reporting with 80% threshold requirement
- HTML and XML coverage report generation
- Custom markers:
unit,integration,slow - Strict configuration and verbose output
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared fixtures
├── test_setup_validation.py # Infrastructure validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Testing Fixtures
Created comprehensive fixtures in tests/conftest.py:
- Sublime Text Mocks:
mock_sublime,mock_view,mock_window,mock_settings - File System Utilities:
temp_dir,temp_filefor temporary test resources - Sample Data:
sample_python_code,kite_response_mockfor consistent test data - Configuration Mocks:
mock_kite_settings,mock_platform_info
Coverage Configuration
- Source Tracking: Configured to track coverage for
lib/directory - Exclusions: Properly excludes test files, vendor code, and cache directories
- Reporting: Multiple formats (terminal, HTML, XML) for different use cases
- CI/CD Ready: XML output compatible with most CI/CD platforms
Development Workflow
- Gitignore Updates: Added comprehensive entries for Python artifacts, testing files, coverage reports, and IDE files
- Validation: Included validation tests to ensure infrastructure works correctly
Running Tests
Install Dependencies
poetry install
Run All Tests
poetry run pytest
Run with Coverage
poetry run pytest --cov=lib --cov-report=html
Run Specific Test Types
# Unit tests only
poetry run pytest -m unit
# Integration tests only
poetry run pytest -m integration
# Exclude slow tests
poetry run pytest -m "not slow"
View Coverage Report
After running tests with coverage, open htmlcov/index.html in a browser for detailed coverage analysis.
Validation
✅ All dependencies install correctly
✅ pytest discovers and runs tests successfully
✅ Coverage reporting generates HTML and XML outputs
✅ Custom markers work as expected
✅ Shared fixtures are available across test modules
✅ Validation tests pass confirming infrastructure setup
Notes
- The 80% coverage threshold is configured but will only apply when actual tests are written for the codebase
- Poetry lock file is included and should be committed to ensure consistent dependency versions
- All testing artifacts (coverage reports, cache files) are properly gitignored
- The infrastructure is ready for immediate use - developers can start writing tests in the
tests/unit/andtests/integration/directories
Next Steps
With this infrastructure in place, developers can:
- Start writing unit tests for individual modules in
tests/unit/ - Create integration tests for component interactions in
tests/integration/ - Use the provided fixtures to mock Sublime Text components consistently
- Monitor code coverage and maintain the 80% threshold as the test suite grows