Skip to content

Latest commit

 

History

History
80 lines (63 loc) · 3.88 KB

File metadata and controls

80 lines (63 loc) · 3.88 KB

Testing

Running Tests

# All tests - parallel across every core (pytest-xdist, `-n auto` in pytest.ini)
pytest tests/ -v

# Single file - naming test files runs them in one process, since a worker's
# torch import costs more than it saves there; -n N forces workers anyway
pytest tests/test_security.py -v

# Debugging with -s or --pdb needs one process
pytest tests/ -n0 -s

# The real-model tests (an accelerator, plus SD 1.5 and facebook/mms-tts-eng,
# which download on first run) are the release gate, and are
# excluded by default; one process, since each test holds a model on the device
pytest tests/ -m integration -n0

# Match pattern
pytest tests/ -k "variables" -v

# Stop on first failure
pytest tests/ -x

# With coverage
pytest tests/ --cov=dw --cov-report=html
# Open htmlcov/index.html to view report

Test Files

Around 120 files and 3,600+ tests as of this writing (pytest tests/ --collect-only -q for the current count). The table below maps the core areas; newer features carry their own test_<feature>.py alongside them (server: test_server.py, events/cancellation: test_events.py, test_worker_execute.py, introspection: test_introspection.py, hub cache: test_hub_cache.py, chaining: test_chain.py).

File Area
test_security.py Path, URL, input validation
test_variables.py Variable substitution
test_workflow.py Workflow loading, validation, result eviction, seed resolution
test_previous_results.py Cross-step result references / cartesian products
test_result.py Output file handling
test_arguments.py Argument processing and type conversion
test_step.py Step execution
test_gather.py Resource gathering tasks
test_type_helpers.py Dynamic type loading
test_integration.py End-to-end workflow tests
test_task.py Task dispatch
test_schema.py JSON schema validation
test_worker.py Worker subprocess
test_worker_manager.py Worker process lifecycle management
test_pipeline_caching.py, test_pipeline_components.py, test_modular_pipeline.py Pipeline caching, component discovery, load_components
test_device.py, test_device_helpers.py Device selection, shared device/dtype helpers
test_image_utils.py, test_resize_bucket.py, test_strip_exif_and_watermark.py, test_tensor_image.py, test_list_images.py Image processing task commands
test_diffusion_upscale.py, test_interpolate_frames.py, test_depth_estimator.py, test_segment.py Diffusion upscale, RIFE interpolation, depth hints, segmentation
test_image_to_text.py, test_text_generation.py Captioning and text generation tasks
test_model_cache.py Shared task model cache
test_prompt_weighting.py Prompt weighting device handling
test_argument_updates.py Cached pipelines pick up fresh arguments across runs
test_examples.py Validates every workflow in workflows/ against the schema
test_mcp_client.py, test_mcp_catalog.py, test_mcp_authoring.py, test_mcp_diagnose.py, test_mcp_media.py, test_mcp_server.py MCP tool surface

The MCP tests fake the REST API with httpx.MockTransport — they never start a dw.serve process and never touch a GPU. test_mcp_server.py (which builds a real MCPServer and calls tools through it) skips with pytest.importorskip("mcp", ...) when the mcp extra is not installed.

conftest.py

An autouse _clear_task_model_cache fixture clears dw.tasks.model_cache before and after every test, so a cache hit in one test can't starve a later test's mocked loader of the call it expects. Test-specific fixtures (test_data_dir, temp_output_dir, temp_image, valid_workflow_json, etc.) are also defined here — see tests/README.md for the list.

Quick Validation

# End-to-end check: downloads SD 1.5 and generates one image
python -m dw.test

# Validate a workflow against schema
python -m dw.validate workflows/models/flux-dev.json