-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.py
More file actions
65 lines (50 loc) · 1.7 KB
/
test_runner.py
File metadata and controls
65 lines (50 loc) · 1.7 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
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Simple test runner script for YT-Tutor project.
Usage: python test_runner.py [--coverage]
"""
import sys
import subprocess
import argparse
def run_tests(with_coverage=False):
"""Run the test suite with optional coverage reporting"""
if with_coverage:
cmd = [
"uv", "run", "pytest", "tests/",
"--cov=main",
"--cov-report=term-missing",
"--cov-report=html",
"-v"
]
print("Running tests with coverage...")
else:
cmd = ["uv", "run", "pytest", "tests/", "-v"]
print("Running tests...")
try:
result = subprocess.run(cmd, check=True)
print(f"\n✅ All tests passed!")
if with_coverage:
print("\n📊 Coverage report generated:")
print(" - Terminal report displayed above")
print(" - HTML report: htmlcov/index.html")
return 0
except subprocess.CalledProcessError as e:
print(f"\n❌ Tests failed with exit code {e.returncode}")
return e.returncode
except FileNotFoundError:
print("\n❌ Error: 'uv' command not found. Please install uv first.")
print("Visit: https://docs.astral.sh/uv/getting-started/installation/")
return 1
def main():
parser = argparse.ArgumentParser(description="Run YT-Tutor tests")
parser.add_argument(
"--coverage",
action="store_true",
help="Run tests with coverage reporting"
)
args = parser.parse_args()
print("YT-Tutor Test Runner")
print("=" * 50)
return run_tests(with_coverage=args.coverage)
if __name__ == "__main__":
sys.exit(main())