forked from mtusi2026/mtusi2026lab2
Lab2 grade 4: PostgreSQL, Redis sessions, Compose, student tests and evidence.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/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_api",
|
||||
"test_concurrency",
|
||||
"test_sessions",
|
||||
"test_deps",
|
||||
]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
failed = 0
|
||||
passed = 0
|
||||
for name in MODULES:
|
||||
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())
|
||||
Reference in New Issue
Block a user