Skip to content

no-raw-source-text-test-oracle

Test uses raw text from a source-like project path as its oracle.

Why

Substring and regex checks can pass on comments or unreachable configuration and fail after behavior-preserving formatting changes.

Fix

Parse the artifact, execute its validator, or assert on a runtime contract. If exact bytes or text are the deliberate compatibility contract, use an exact line suppression with the reason.

Examples

Before — flagged Do not prove workflow behavior with a substring
tests/test_policy.py
from pathlib import Path
def test_policy():
source = Path("workflow.yml").read_text()
assert "permissions:" in source
After — preferred Assert on parsed workflow behavior
tests/test_policy.py
from pathlib import Path
import yaml
def test_policy():
workflow = yaml.safe_load(Path("workflow.yml").read_text())
assert workflow["permissions"]["contents"] == "read"

Formerly: source-coupled-test