feat: Set up comprehensive Python testing infrastructure with Poetry
Set Up Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the Radiata project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Poetry Configuration: Created
pyproject.tomlwith complete Poetry setup - Dependency Migration: Migrated all dependencies from
requirements/*.txtfiles to Poetry - Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies
Testing Framework Setup
-
Pytest Configuration:
- Configured test discovery patterns for
test_*.pyand*_test.pyfiles - Set up coverage reporting with HTML and XML output formats
- Added strict markers and verbose output for better test visibility
- Configured coverage to track
api,lib, andmodulesdirectories
- Configured test discovery patterns for
-
Test Markers: Added custom markers for test organization:
@pytest.mark.unit- For unit tests@pytest.mark.integration- For integration tests@pytest.mark.slow- For slow-running tests
Directory Structure
tests/
├── __init__.py
├── conftest.py # Shared pytest fixtures
├── test_setup_validation.py # Validation tests
├── unit/
│ └── __init__.py
└── integration/
└── __init__.py
Shared Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir- Temporary directory managementmock_config- Mock configuration dictionariesmock_model- Mock diffusion modelssample_image_path- Test image generationmock_gradio_interface- Mock Gradio interfacesenv_vars- Environment variable managementmock_torch- Mock PyTorch for CPU-only testsmock_pipeline- Mock diffusion pipelinescapture_logs- Log capturing during tests
Configuration Files
- pyproject.toml: Complete Poetry and testing configuration
- .gitignore: Updated to exclude testing artifacts while keeping poetry.lock
Running Tests
Install Dependencies
poetry install --with dev
Run Tests
You can run tests using either command:
poetry run test
# or
poetry run tests
Run Specific Test Markers
# Run only unit tests
poetry run pytest -m unit
# Run only integration tests
poetry run pytest -m integration
# Exclude slow tests
poetry run pytest -m "not slow"
Coverage Reports
- Terminal: Coverage summary is displayed after each test run
- HTML Report: Open
htmlcov/index.htmlin a browser - XML Report: Available at
coverage.xmlfor CI integration
Notes
- Coverage Threshold: Currently set to 0% to allow initial setup. Should be increased to 80% as tests are added to the codebase.
- Poetry Lock File: The
poetry.lockfile should be committed to ensure reproducible builds. - No Production Tests: This PR only sets up the infrastructure. Actual unit tests for the codebase should be added in subsequent PRs.
Validation
The setup includes validation tests (test_setup_validation.py) that verify:
- Project structure exists correctly
- Configuration files are properly set up
- All fixtures are functional
- Test markers work as expected
- Coverage reporting is configured
- Poetry scripts are available
All validation tests pass successfully, confirming the infrastructure is ready for use.
The name of this project is not Stable Diffusion WebUI Forge, but Radiata.
Oops, you are absolutely right. Thank you so much for catching that!
It looks like a cached project name from a previous run slipped into the PR description. Will get it fixed.
Hmm. Or maybe it was something else. Anyways, I updated the pull request description and I fixed The poetry files. There was some security issues with some of the older packages. So everything's happy now with Python 3.11. We'll be ready to add actual tests after this is merged now.