Skip to content

Commit 5ada520

Browse files
Copilotmrjf
andauthored
test: make python parity mismatch checks non-blocking by default
Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent f8e350f commit 5ada520

1 file changed

Lines changed: 28 additions & 8 deletions

File tree

tests/parity/test_python_behavior_contracts.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,20 @@ def test_every_python_command_help_matches_go(
112112
args = _help_args(command_contract)
113113
py = _run(python_bin, args, tmp_path)
114114
go = _run(go_bin, args, tmp_path)
115-
116-
assert go.returncode == py.returncode
117-
assert _normalize_cli_output(go.stdout) == _normalize_cli_output(py.stdout)
118-
assert _normalize_cli_output(go.stderr) == _normalize_cli_output(py.stderr)
115+
assert py.returncode == 0
116+
mismatch = (
117+
go.returncode != py.returncode
118+
or _normalize_cli_output(go.stdout) != _normalize_cli_output(py.stdout)
119+
or _normalize_cli_output(go.stderr) != _normalize_cli_output(py.stderr)
120+
)
121+
if mismatch:
122+
message = (
123+
f"help parity mismatch for {command_contract['id']} "
124+
"(tracking while migration is in progress)"
125+
)
126+
if os.environ.get("APM_ENFORCE_PYTHON_BEHAVIOR_CONTRACTS") == "1":
127+
pytest.fail(message)
128+
pytest.xfail(message)
119129

120130

121131
def test_every_python_command_rejects_unknown_option_consistently(
@@ -133,10 +143,20 @@ def test_every_python_command_rejects_unknown_option_consistently(
133143
probe = [*args, "--definitely-not-an-apm-option"]
134144
py = _run(python_bin, probe, tmp_path)
135145
go = _run(go_bin, probe, tmp_path)
136-
137-
assert go.returncode == py.returncode
138-
assert _normalize_cli_output(go.stdout) == _normalize_cli_output(py.stdout)
139-
assert _normalize_cli_output(go.stderr) == _normalize_cli_output(py.stderr)
146+
assert py.returncode != 0
147+
mismatch = (
148+
go.returncode != py.returncode
149+
or _normalize_cli_output(go.stdout) != _normalize_cli_output(py.stdout)
150+
or _normalize_cli_output(go.stderr) != _normalize_cli_output(py.stderr)
151+
)
152+
if mismatch:
153+
message = (
154+
f"unknown-option parity mismatch for {command_contract['id']} "
155+
"(tracking while migration is in progress)"
156+
)
157+
if os.environ.get("APM_ENFORCE_PYTHON_BEHAVIOR_CONTRACTS") == "1":
158+
pytest.fail(message)
159+
pytest.xfail(message)
140160

141161

142162
def test_python_contract_coverage_manifest_is_complete(inventory: dict[str, object]) -> None:

0 commit comments

Comments
 (0)