CTags
CTags copied to clipboard
feat: Set up comprehensive Python testing infrastructure with Poetry
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the ANSI Color Build Sublime Text plugin using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Set up Poetry as the package manager (created
pyproject.toml) - Added testing dependencies as development dependencies:
pytest- Main testing frameworkpytest-cov- Coverage reportingpytest-mock- Mocking utilities
Testing Configuration
- Configured pytest in
pyproject.tomlwith:- Test discovery patterns for
test_*.pyand*_test.py - Coverage settings with 80% threshold
- HTML and XML coverage report generation
- Custom test markers:
unit,integration,slow - Strict mode with verbose output
- Test discovery patterns for
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared pytest fixtures
├── test_setup_validation.py # Validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Development Commands
Both of these commands work to run tests:
poetry run testpoetry run tests
Shared Fixtures (conftest.py)
Created comprehensive fixtures for testing Sublime Text plugins:
temp_dir- Temporary directory managementtemp_file- Temporary file creationmock_sublime- Mock sublime module with all constants and methodsmock_sublime_plugin- Mock sublime_plugin classes (TextCommand, WindowCommand, EventListener)mock_view- Mock Sublime Text view objectsmock_window- Mock Sublime Text window objectsmock_settings- Mock settings with get/set/has/erase functionalitysample_ansi_output- Sample ANSI colored strings for testingreset_modules- Auto-cleanup of imported modules between testscapture_stdout- Stdout capture for testing print statements
Updated .gitignore
Added comprehensive testing-related entries:
- Coverage files (
.coverage,htmlcov/,coverage.xml) - Claude configuration (
.claude/*) - Build artifacts and virtual environments
- IDE files
How to Use
-
Install dependencies:
poetry install -
Run all tests:
poetry run test # or poetry run tests -
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:
- Terminal: Coverage is shown after each test run
- HTML: Open
htmlcov/index.htmlin a browser - XML: Available at
coverage.xmlfor CI integration
Notes
- The 80% coverage threshold is currently not met since no actual tests for the codebase exist yet
- This setup provides all the infrastructure needed to start writing comprehensive tests
- All validation tests pass, confirming the testing environment is properly configured
- Poetry lock file (
poetry.lock) is tracked in git for reproducible builds