SimpleChatbot / scripts /verify_ci_failure_contract.py
Amin
Deploy: HermesFace finalized project to HF Space
2e658e7
Raw
History Blame Contribute Delete
874 Bytes
#!/usr/bin/env python3
"""Prove that the configured test runner returns non-zero on a failing test."""
from __future__ import annotations
import subprocess
import sys
import tempfile
from pathlib import Path
def main() -> int:
with tempfile.TemporaryDirectory(prefix="hermes-ci-failure-") as tmp:
test_file = Path(tmp) / "test_intentional_failure.py"
test_file.write_text("def test_intentional_failure():\n assert False\n", encoding="utf-8")
result = subprocess.run(
[sys.executable, "-m", "pytest", str(test_file), "-q"],
capture_output=True,
text=True,
)
if result.returncode == 0:
print("ERROR: pytest returned success for an intentionally failing test")
return 1
print("ci_failure_contract=PASS")
return 0
if __name__ == "__main__":
raise SystemExit(main())