mlsql
mlsql copied to clipboard
feat: Set up Python testing infrastructure with Poetry and pytest
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.tomlwith 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_*.pyand*_test.py - Custom markers:
unit,integration,slow - Verbose output with short traceback format
- Coverage settings configured (ready for future use)
- Test discovery patterns:
Test Fixtures (conftest.py)
Created comprehensive fixtures for common testing scenarios:
temp_dir: Temporary directory managementsample_csv_file: CSV file creation for testingsample_sqlite_db: SQLite database with test datamock_config: Configuration dictionarymock_api_request/mock_sql_response: API testing helpersmock_model_predictions: Model output mockingreset_environment: Environment variable isolationcaptured_logs: Log capture utilitymock_http_response: HTTP response mocking
Validation
- Created
test_infrastructure.pywith 12 validation tests - All tests pass successfully, confirming proper setup
Other Changes
- Created
.gitignorewith comprehensive Python patterns - Added Claude-specific entries to gitignore
How to Use
-
Install dependencies:
poetry install -
Run all tests:
poetry run pytestor
poetry run test # or 'poetry run tests' -
Run specific test categories:
poetry run pytest -m unit poetry run pytest -m integration poetry run pytest -m "not slow" -
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
- Developers can now write unit tests in
tests/unit/ - Integration tests go in
tests/integration/ - Use the provided fixtures for common testing patterns
- Add project dependencies to pyproject.toml as needed