MogensR's picture
Create tests/__init__.py
d02fbe8
raw
history blame
1.85 kB
"""
BackgroundFX Pro Test Suite.
Comprehensive testing for all modules.
"""
import os
import sys
from pathlib import Path
# Add parent directory to path for imports
parent_dir = Path(__file__).parent.parent
sys.path.insert(0, str(parent_dir))
# Test categories
TEST_CATEGORIES = {
'unit': 'Unit tests for individual components',
'integration': 'Integration tests for component interactions',
'api': 'API endpoint tests',
'models': 'Model management tests',
'pipeline': 'Processing pipeline tests',
'performance': 'Performance and benchmark tests',
'gpu': 'GPU-specific tests'
}
def run_tests(category: str = None, verbose: bool = True):
"""
Run tests for BackgroundFX Pro.
Args:
category: Optional test category to run
verbose: Enable verbose output
"""
import pytest
args = []
if category:
if category in TEST_CATEGORIES:
args.extend(['-m', category])
else:
print(f"Unknown category: {category}")
print(f"Available categories: {', '.join(TEST_CATEGORIES.keys())}")
return 1
if verbose:
args.append('-v')
# Add coverage by default
args.extend(['--cov=.', '--cov-report=term-missing'])
return pytest.main(args)
def run_quick_tests():
"""Run quick unit tests only (no slow/integration tests)."""
import pytest
return pytest.main(['-m', 'not slow and not integration', '-v'])
def run_gpu_tests():
"""Run GPU-specific tests if GPU is available."""
import torch
if not torch.cuda.is_available():
print("No GPU available, skipping GPU tests")
return 0
import pytest
return pytest.main(['-m', 'gpu', '-v'])
__all__ = [
'run_tests',
'run_quick_tests',
'run_gpu_tests',
'TEST_CATEGORIES'
]