ComfyUI-SAM3DBody Tests
This directory contains unit and integration tests for ComfyUI-SAM3DBody.
Test Structure
conftest.py- Pytest configuration and ComfyUI mockingtest_node_registration.py- Unit tests for node registration (fast)test_inference.py- Integration tests with real models (slow)
Running Tests
Install Test Dependencies
pip install pytest pytest-cov
Run All Tests
pytest tests/ -v
Run Only Unit Tests (Fast)
pytest tests/ -v -m unit
Run Only Integration Tests (Slow)
Requires HuggingFace token for model downloads:
export HF_TOKEN=your_token_here
pytest tests/ -v -m integration
Or run specific integration tests:
pytest tests/test_inference.py -v -s -m integration
Run Tests with Coverage
pytest tests/ -v --cov=nodes --cov=sam_3d_body --cov-report=html
Then open htmlcov/index.html to view the coverage report.
Test Markers
Tests are organized using pytest markers:
@pytest.mark.unit- Fast tests, no model loading required@pytest.mark.integration- Slow tests with real model inference
CI/CD
Tests run automatically on push/PR via GitHub Actions:
- test-install: Runs unit tests on Ubuntu, Windows, macOS
- test-cpu-inference: Runs integration tests with CPU inference
See .github/workflows/test-install.yml for details.
Adding New Tests
When adding new nodes or features:
- Add unit tests to
test_node_registration.pyfor structure validation - Add integration tests to
test_inference.pyfor actual functionality - Use appropriate markers (
@pytest.mark.unitor@pytest.mark.integration) - Update this README if needed
Troubleshooting
ComfyUI Import Errors
The conftest.py file mocks all ComfyUI dependencies. If you see import errors, ensure:
- Tests are run from the repository root
- The conftest.py is properly mocking ComfyUI modules
- Node imports are direct (not through
__init__.py)
Integration Test Failures
Integration tests require:
- HuggingFace token (
HF_TOKENenvironment variable) - Internet connection for model downloads
- Sufficient disk space (~5GB for model cache)
- Time (first run downloads models, subsequent runs use cache)
Skipping __init__.py
The __init__.py file has pytest detection and will skip loading nodes during tests. To force initialization (not recommended):
SAM3DB_FORCE_INIT=1 pytest tests/