-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
53 lines (43 loc) · 1.68 KB
/
run_tests.py
File metadata and controls
53 lines (43 loc) · 1.68 KB
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
#!/usr/bin/env python
"""
Test runner for fast_c2pa_python.
This script runs both API compatibility tests and performance benchmarks.
"""
import os
import sys
import pytest
import argparse
from pathlib import Path
def main():
"""Run tests for fast_c2pa_python."""
parser = argparse.ArgumentParser(description="Run tests for fast_c2pa_python")
parser.add_argument("--api-only", action="store_true", help="Run only API tests")
parser.add_argument("--perf-only", action="store_true", help="Run only performance tests")
parser.add_argument("--image", type=str, help="Path to test image with C2PA metadata")
args = parser.parse_args()
# Set path to test directory
test_dir = Path(__file__).parent / "tests"
# Create test image directory if it doesn't exist
test_images_dir = test_dir / "test_images"
test_images_dir.mkdir(exist_ok=True, parents=True)
# If a test image is provided, copy it to the test directory
if args.image:
import shutil
src_path = Path(args.image).resolve()
if not src_path.exists():
print(f"Error: Test image not found: {src_path}")
return 1
dst_path = test_images_dir / "sample_firefly.jpg"
print(f"Copying test image from {src_path} to {dst_path}")
shutil.copy(src_path, dst_path)
# Determine which tests to run
if args.api_only:
test_paths = [str(test_dir / "test_api.py")]
elif args.perf_only:
test_paths = [str(test_dir / "test_performance.py")]
else:
test_paths = [str(test_dir)]
# Run the tests
return pytest.main(["-v"] + test_paths)
if __name__ == "__main__":
sys.exit(main())