Files
mtusi2026lab5/student-tests/run_all.py
T

50 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Run all student tests against a live API (BASE_URL)."""
from __future__ import annotations
import importlib
import sys
import traceback
MODULES = [
"test_images_unit",
"test_api",
"test_concurrency",
"test_sessions",
"test_idempotency",
"test_attachments",
"test_attachments_ops",
"test_shutdown",
"test_deps",
]
def main() -> int:
failed = 0
passed = 0
only = set(sys.argv[1:])
for name in MODULES:
if only and name not in only:
continue
mod = importlib.import_module(name)
tests = [getattr(mod, n) for n in dir(mod) if n.startswith("test_")]
for fn in tests:
label = f"{name}.{fn.__name__}"
try:
fn()
print("OK", label)
passed += 1
except Exception as exc:
failed += 1
print("FAIL", label, ":", exc)
traceback.print_exc()
print(f"Summary: {passed} passed, {failed} failed")
return 1 if failed else 0
if __name__ == "__main__":
sys.path.insert(0, ".")
raise SystemExit(main())