8000 feat: Set up comprehensive Python testing infrastructure by llbbl · Pull Request #314 · hayaku/hayaku · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Set up comprehensive Python testing infrastructure #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

llbbl
Copy link
@llbbl llbbl commented Jun 20, 2025

Add Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the Hayaku project using Poetry, pytest, and related testing tools. The setup provides a foundation for writing unit and integration tests with proper mocking support for Sublime Text components.

Changes Made

Package Management

  • Configured Poetry as the package manager with package-mode = false (since this is a Sublime Text plugin)
  • Created pyproject.toml with all necessary configuration
  • Added testing dependencies as development dependencies

Testing Framework

  • pytest - Main testing framework
  • pytest-cov - Coverage reporting with 80% threshold
  • pytest-mock - Mocking utilities for test isolation

Configuration

  • Comprehensive pytest configuration in pyproject.toml:
    • Test discovery patterns
    • Coverage settings with HTML and XML reports
    • Custom test markers (unit, integration, slow)
    • Strict mode enabled for better error detection

Directory Structure

tests/
├── __init__.py
├── README.md
├── conftest.py          # Shared fixtures
├── test_setup_validation.py  # Infrastructure validation
├── unit/
│   └── __init__.py
└── integration/
    └── __init__.py

Testing Fixtures

Created comprehensive fixtures in conftest.py:

  • temp_dir - Temporary directory management
  • mock_sublime - Mocked Sublime Text API
  • mock_view - Mocked View objects
  • sample_css_dict - Sample CSS data for testing
  • mock_settings - Hayaku settings configuration
  • temp_css_file - Temporary CSS file creation
  • And more...

Other Updates

  • Updated .gitignore with Python and testing-related patterns
  • Added validation tests to ensure the infrastructure works correctly
  • Created testing README with usage instructions

How to Use

  1. Install dependencies:

    poetry install --no-root
  2. Run tests:

    # Run all tests
    poetry run pytest
    
    # Run with coverage
    poetry run pytest --cov
    
    # Run specific markers
    poetry run pytest -m unit
    poetry run pytest -m integration
  3. View coverage report:

    # Open htmlcov/index.html in browser

Notes

  • The project is configured with package-mode = false in Poetry since this is a Sublime Text plugin that doesn't need to be packaged as a Python library
  • Coverage warnings about "no data collected" are expected when running infrastructure validation tests only
  • The 80% coverage threshold has been temporarily removed from the default options but can be enforced with --cov-fail-under=80
  • All test commands support standard pytest options for filtering, verbosity, etc.

Next Steps

With this infrastructure in place, developers can now:

  1. Write unit tests for individual components
  2. Create integration tests for feature workflows
  3. Mock Sublime Text API interactions effectively
  4. Track test coverage to ensure code quality

- Configure Poetry for dependency management with package-mode=false
- Add pytest, pytest-cov, and pytest-mock as dev dependencies
- Create pytest configuration with coverage reporting and test markers
- Set up testing directory structure with unit/integration separation
- Add shared fixtures for mocking Sublime Text components
- Update .gitignore with testing and Python-related entries
- Create validation tests to verify infrastructure setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0