File size: 1,854 Bytes
d02fbe8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
"""
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'
] |