mirror of
https://github.com/openai/codex-security.git
synced 2026-11-21 02:12:29 +08:00
* docs: document Python module and function contracts * refactor: simplify scan recovery and reporting * test(deep-scan): restore the coordinator stop error import
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Exercise the native-test CI gate with missing, malformed, skipped, and passing reports."""
|
|
|
|
from contextlib import nullcontext
|
|
from pathlib import Path
|
|
from runpy import run_path
|
|
from xml.etree.ElementTree import ParseError
|
|
|
|
import pytest
|
|
|
|
CHECK = Path(__file__).with_name("require_native_python_report.py")
|
|
PASSING = "<testsuite><testcase/></testsuite>"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("report", "outcome"),
|
|
[
|
|
(None, pytest.raises(FileNotFoundError, match="python.xml")),
|
|
("", pytest.raises(ParseError)),
|
|
("<testsuite/>", pytest.raises(SystemExit, match="No native platform tests ran")),
|
|
(
|
|
"<testsuite><testcase/><testcase><skipped/></testcase></testsuite>",
|
|
pytest.raises(SystemExit, match="Native platform tests must run without skips"),
|
|
),
|
|
(PASSING, nullcontext()),
|
|
],
|
|
)
|
|
def test_native_python_report(tmp_path, monkeypatch, report, outcome):
|
|
monkeypatch.chdir(tmp_path)
|
|
reports = Path("reports")
|
|
reports.mkdir()
|
|
(reports / "python-stale.xml").write_text(PASSING)
|
|
if report is not None:
|
|
(reports / "python.xml").write_text(report)
|
|
with outcome:
|
|
run_path(str(CHECK), run_name="__main__")
|