Skip to content

Commit a7882c1

Browse files
committed
check returncode for README test
1 parent 07e5452 commit a7882c1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/test_readme.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414

1515

1616
def test_readme_runs():
17+
"""Execute README code blocks and compare output to documented results."""
1718
code_blocks = CODE_BLOCK.findall(README.read_text())
1819
result_blocks = RESULT.findall(README.read_text())
1920

2021
code = "".join(code_blocks) # merged code
2122
expected = "".join(result_blocks)
2223

23-
result = subprocess.run(
24-
[sys.executable, "-c", code], capture_output=True, text=True
25-
)
24+
# Trust boundary: we execute Python snippets sourced from README.md in this repo.
25+
# The README is part of the trusted repository content and reviewed in PRs.
26+
result = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True) # noqa: S603
2627

2728
stdout = result.stdout
2829

30+
assert result.returncode == 0, f"README code exited with {result.returncode}. Stderr:\n{result.stderr}"
2931
assert stdout.strip() == expected.strip()

0 commit comments

Comments
 (0)