Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Conversation

@llbbl
Copy link

@llbbl llbbl commented Jun 17, 2025

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.toml with complete Poetry setup
  • Dependency Migration: Migrated all dependencies from requirements/*.txt files 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_*.py and *_test.py files
    • 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, and modules directories
  • 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 management
  • mock_config - Mock configuration dictionaries
  • mock_model - Mock diffusion models
  • sample_image_path - Test image generation
  • mock_gradio_interface - Mock Gradio interfaces
  • env_vars - Environment variable management
  • mock_torch - Mock PyTorch for CPU-only tests
  • mock_pipeline - Mock diffusion pipelines
  • capture_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.html in a browser
  • XML Report: Available at coverage.xml for 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.lock file 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.

- Configured Poetry as package manager with pyproject.toml
- Added testing dependencies: pytest, pytest-cov, pytest-mock
- Set up pytest configuration with coverage reporting
- Created test directory structure (tests/unit, tests/integration)
- Added shared fixtures in conftest.py for common testing needs
- Configured test markers for unit, integration, and slow tests
- Set up Poetry scripts for running tests (poetry run test/tests)
- Updated .gitignore to exclude testing artifacts
- Created validation tests to verify infrastructure setup
@fa0311
Copy link
Contributor

fa0311 commented Jun 17, 2025

The name of this project is not Stable Diffusion WebUI Forge, but Radiata.

@llbbl
Copy link
Author

llbbl commented Jun 17, 2025

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.

- Bumped Python version to 3.11
- Upgraded multiple dependencies to latest compatible versions
- Removed outdated and unused package entries
- Some CVE warnings in the older ~3.8 packages
@llbbl
Copy link
Author

llbbl commented Jun 17, 2025

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants