Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Jun 27, 2025

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the text-to-SQL models project using Poetry for dependency management and pytest as the testing framework.

Changes Made

Package Management

  • Configured Poetry as the package manager with package-mode = false (dependency management only)
  • Created pyproject.toml with project metadata and dependencies
  • Added development dependencies: pytest, pytest-cov, pytest-mock

Testing Framework Setup

  • Directory Structure:

    tests/
    ├── __init__.py
    ├── conftest.py
    ├── test_infrastructure.py
    ├── unit/
    │   └── __init__.py
    └── integration/
        └── __init__.py
    
  • pytest Configuration:

    • Test discovery patterns: test_*.py and *_test.py
    • Custom markers: unit, integration, slow
    • Verbose output with short traceback format
    • Coverage settings configured (ready for future use)

Test Fixtures (conftest.py)

Created comprehensive fixtures for common testing scenarios:

  • temp_dir: Temporary directory management
  • sample_csv_file: CSV file creation for testing
  • sample_sqlite_db: SQLite database with test data
  • mock_config: Configuration dictionary
  • mock_api_request/mock_sql_response: API testing helpers
  • mock_model_predictions: Model output mocking
  • reset_environment: Environment variable isolation
  • captured_logs: Log capture utility
  • mock_http_response: HTTP response mocking

Validation

  • Created test_infrastructure.py with 12 validation tests
  • All tests pass successfully, confirming proper setup

Other Changes

  • Created .gitignore with comprehensive Python patterns
  • Added Claude-specific entries to gitignore

How to Use

  1. Install dependencies:

    poetry install
  2. Run all tests:

    poetry run pytest

    or

    poetry run test  # or 'poetry run tests'
  3. Run specific test categories:

    poetry run pytest -m unit
    poetry run pytest -m integration
    poetry run pytest -m "not slow"
  4. Run with coverage (when ready):

    poetry run pytest --cov=irnet --cov=valuenet

Notes

  • The infrastructure is ready for developers to start writing tests
  • No actual unit tests for the codebase were created - only infrastructure setup
  • The main project dependencies (Flask, transformers, etc.) were not included to avoid installation issues during setup
  • Coverage reporting is configured but not enforced initially

Next Steps

  1. Developers can now write unit tests in tests/unit/
  2. Integration tests go in tests/integration/
  3. Use the provided fixtures for common testing patterns
  4. Add project dependencies to pyproject.toml as needed

- Configure Poetry for dependency management (package-mode disabled)
- Add pytest, pytest-cov, and pytest-mock as dev dependencies
- Create test directory structure with unit and integration subdirs
- Configure pytest settings with custom markers and test discovery
- Add comprehensive test fixtures in conftest.py
- Create validation tests to verify infrastructure setup
- Update .gitignore with testing and Claude-related 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.

1 participant