Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Sep 3, 2025

Set up Python Testing Infrastructure

Summary

This PR establishes a complete testing infrastructure for the odoo-stubs project, providing developers with the tools and configuration needed to write and run tests effectively.

Changes Made

Package Management

  • Added Poetry configuration in pyproject.toml
  • Migrated project metadata from setup.py to modern Poetry format
  • Added development dependencies: pytest, pytest-cov, pytest-mock

Testing Configuration

  • Comprehensive pytest settings with coverage reporting (80% threshold)
  • Custom test markers: unit, integration, slow for test categorization
  • Coverage configuration with HTML, XML, and terminal reports
  • Strict pytest options for better test reliability

Directory Structure

tests/
├── __init__.py
├── conftest.py           # Shared fixtures
├── test_infrastructure.py # Validation tests
├── unit/
│   └── __init__.py
└── integration/
    └── __init__.py

Testing Utilities

  • Shared fixtures in conftest.py:
    • temp_dir: Temporary directory with automatic cleanup
    • sample_stub_content: Sample .pyi file content for testing
    • mock_odoo_env: Mock Odoo environment for isolated testing
    • stub_file: Creates temporary stub files for testing

Development Environment

  • Updated .gitignore with testing artifacts, IDE files, and Python-specific entries
  • Validation tests to ensure infrastructure works correctly
  • Poetry lock file for reproducible environments

Running Tests

After this PR is merged, developers can run tests using:

# Install dependencies
poetry install

# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov=odoo-stubs

# Run specific test types
poetry run pytest -m unit          # Unit tests only
poetry run pytest -m integration   # Integration tests only
poetry run pytest -m "not slow"    # Skip slow tests

# Run tests without coverage
poetry run pytest --no-cov

Coverage Reports

The setup generates multiple coverage report formats:

  • Terminal output: Shows missing lines during test runs
  • HTML report: Detailed browser-viewable report in htmlcov/
  • XML report: For CI/CD integration in coverage.xml

Next Steps

With this infrastructure in place, developers can:

  1. Write unit tests for individual stub files
  2. Create integration tests for cross-module functionality
  3. Add performance tests for large stub file processing
  4. Set up CI/CD pipelines using the XML coverage reports

The validation tests confirm the infrastructure is working correctly and ready for development use.

- Add Poetry configuration in pyproject.toml with dev dependencies
- Configure pytest with coverage reporting, markers, and strict settings
- Create tests/ directory structure with unit/integration subdirectories
- Add shared fixtures in conftest.py for testing stub files
- Include validation tests to verify infrastructure setup
- Update .gitignore with testing and development entries
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.

2 participants