-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_tests.py
More file actions
58 lines (44 loc) · 1.49 KB
/
Copy pathrun_tests.py
File metadata and controls
58 lines (44 loc) · 1.49 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
#!/usr/bin/env python3
"""Test runner script for Időkép integration."""
import argparse
import subprocess
import sys
from pathlib import Path
def run_tests(*, coverage: bool = True, verbose: bool = True) -> int:
"""Run the test suite."""
cmd = ["python", "-m", "pytest", "tests/"]
if verbose:
cmd.append("-v")
if coverage:
cmd.extend(
[
"--cov=custom_components.idokep",
"--cov-report=term-missing",
"--cov-report=html",
]
)
try:
result = subprocess.run(cmd, cwd=Path(__file__).parent, check=False)
except KeyboardInterrupt:
print("\nTest run cancelled by user")
return 1
else:
return result.returncode
def main() -> None:
"""Run the main entry point."""
parser = argparse.ArgumentParser(description="Run Időkép integration tests")
parser.add_argument(
"--no-coverage", action="store_true", help="Skip coverage reporting"
)
parser.add_argument("--quiet", action="store_true", help="Reduce output verbosity")
args = parser.parse_args()
exit_code = run_tests(coverage=not args.no_coverage, verbose=not args.quiet)
if exit_code == 0:
print("\n✅ All tests passed!")
if not args.no_coverage:
print("📊 Coverage report generated in htmlcov/index.html")
else:
print(f"\n❌ Tests failed with exit code {exit_code}")
sys.exit(exit_code)
if __name__ == "__main__":
main()