feat: Add comprehensive Python testing infrastructure with Poetry by llbbl · Pull Request #172 · xdevplatform/search-tweets-python · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

feat: Add comprehensive Python testing infrastructure with Poetry #172

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 28, 2025

Add Python Testing Infrastructure

Summary

This PR sets up a comprehensive testing infrastructure for the search-tweets-python project using Poetry as the package manager and pytest as the testing framework. The infrastructure provides a solid foundation for writing and organizing tests with proper coverage reporting and test categorization.

Changes Made

Package Management

  • Poetry Setup: Created pyproject.toml with Poetry configuration
  • Dependency Migration: Migrated existing dependencies from setup.py to Poetry format
  • Development Dependencies: Added pytest (^7.4.0), pytest-cov (^4.1.0), and pytest-mock (^3.11.1)

Testing Configuration

  • pytest Configuration:

    • Configured test discovery patterns
    • Set up coverage reporting with HTML and XML output
    • Added strict markers and output formatting
    • Created custom markers: unit, integration, slow
  • Coverage Settings:

    • Set 80% coverage threshold (currently disabled for validation tests)
    • Configured source directories and exclusions
    • Added multiple report formats (terminal, HTML, XML)

Directory Structure

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

Shared Fixtures (conftest.py)

  • temp_dir: Creates temporary directories for testing
  • mock_config: Provides mock configuration dictionaries
  • mock_yaml_config: Creates temporary YAML config files
  • mock_credentials: Mock API credentials
  • mock_tweet_response: Sample API response data
  • mock_search_params: Search parameter examples
  • setup_test_environment: Clears environment variables
  • capture_logs: Log capture utility

Additional Files

  • Makefile: Convenient commands for running tests
  • .gitignore: Updated with testing and Claude-specific patterns

How to Use

Installation

# Install all dependencies including dev dependencies
poetry install

Running Tests

# Run all tests
poetry run pytest
# or
make test
# or
make tests

# Run only unit tests
poetry run pytest -m unit
# or
make test-unit

# Run only integration tests
poetry run pytest -m integration
# or
make test-integration

# Run with coverage enforcement
make test-coverage

Writing Tests

  1. Place unit tests in tests/unit/
  2. Place integration tests in tests/integration/
  3. Use the provided fixtures from conftest.py
  4. Mark tests appropriately:
    @pytest.mark.unit
    def test_something():
        pass
    
    @pytest.mark.integration
    def test_api_call():
        pass
    
    @pytest.mark.slow
    def test_long_running():
        pass

Notes

  • The validation tests confirm the infrastructure is working correctly
  • Coverage is currently low (23.55%) as only infrastructure validation tests exist
  • The 80% coverage threshold is configured but not enforced in CI to allow gradual test addition
  • Poetry lock file (poetry.lock) should be committed to ensure reproducible builds

Next Steps

  • Start writing unit tests for existing modules
  • Add integration tests for API functionality
  • Set up CI/CD pipeline to run tests automatically
  • Consider adding additional testing tools (e.g., hypothesis for property-based testing)

- Set up Poetry as package manager with pyproject.toml configuration
- Add pytest, pytest-cov, and pytest-mock as development dependencies
- Configure pytest with coverage reporting (HTML, XML, terminal)
- Create test directory structure (unit/integration separation)
- Add shared pytest fixtures in conftest.py
- Set up test markers (unit, integration, slow)
- Create validation tests to verify infrastructure
- Update .gitignore with testing and Claude-specific patterns
- Add Makefile with convenient test commands
@CLAassistant
Copy link

CLAassistant commented Jun 28, 2025

CLA assistant check
All committers have signed the CLA.

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

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.