Commit fc75b66
docs(tests): correct the e2e expected-failure helper guidance (#2252)
* docs(tests): correct the e2e expected-failure helper guidance
tests/AGENTS.md told tests expecting a tool failure to use
safe_call_tool() directly. The harness disagrees: MCPAssertions
.call_tool_failure() is used at 61 call sites across 13 e2e files and
does strictly more -- it catches the ToolError, asserts the call
actually failed rather than silently succeeding, and matches
expected_error against the extracted message.
safe_call_tool() swallows ToolError and returns a parsed dict, so using
it for an expected failure leaves nothing verifying the call failed. Its
real roles are finally-block cleanup and availability probing, which the
entry now says.
CodeRabbit cites the old line as a coding-guidelines violation whenever
call_tool_failure appears, most recently on #2246.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c4gkE9mcKu4RiuQzR5eff
* docs(tests): scope the failure-helper claim and fix safe_call_tool's docstring
Two corrections from Codex review:
call_tool_failure() only proves the call failed when expected_error is
given. assert_mcp_failure()'s check is `if data.get("success")`, so a
result dict that omits the key entirely is accepted as a failure. The
guidance now says to pass expected_error and states the limitation
rather than claiming the helper always proves failure.
safe_call_tool()'s own docstring still advertised it as the helper for
tests that expect a failure, contradicting the new rule in a second
place and recreating the ambiguity this branch removes. It now names its
real roles -- finally-block cleanup and availability probing -- and
points at call_tool_failure() for asserted failures.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c4gkE9mcKu4RiuQzR5eff
* docs(tests): do not require expected_error the suite does not pass
The previous wording made expected_error mandatory. 30 of the 61
call_tool_failure() sites omit it and assert on the returned dict
themselves, so that rule would have been broken by half the suite on the
day it landed -- the same doc-contradicts-code problem this branch
exists to fix.
Now stated as a preference, with manual post-assertion named as the
equally valid alternative, and the actual failure mode (omitting both)
called out.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c4gkE9mcKu4RiuQzR5eff
* fix(tests): make assert_mcp_failure reject every success shape
assert_mcp_failure guarded on `if data.get("success")`, so a result dict
that succeeds WITHOUT that key -- ha_manage_app's pending_restart write,
bulk-operation payloads carrying total_operations/results -- was
accepted as a failure. An expected-failure test whose tool regressed to
one of those shapes passed silently, and 30 of the 61 call_tool_failure
sites omit expected_error, so nothing else caught it either.
The success-indicator list assert_mcp_success already maintained is now
a shared `looks_like_success()` predicate used by both sides, so the two
cannot disagree about what success means. call_tool_failure's own
ToolError branch uses it too.
Documented in tests/AGENTS.md alongside it: the helper now proves
failure on its own, and expected_error pins which failure.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c4gkE9mcKu4RiuQzR5eff
* test(e2e): pin assert_mcp_failure against every success shape
The helper fix in fa09814 had no regression test, and this is the class
of harness bug that degrades into a green run rather than a red one --
exactly why test_e2e_assertions.py exists.
Covers the shapes that used to slip through as failures (pending_restart,
bulk payloads keyed on total_operations/results, data-without-error),
the genuine failures that must still pass, expected_error matching on a
real failure, and pending_restart carrying an explicit error (which the
success predicate guards on error is None, so it stays a failure).
Four of the five success-shape cases fail against the pre-fix guard:
data.get("success") on a dict lacking the key is None, so nothing raised.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c4gkE9mcKu4RiuQzR5eff
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 45824cd commit fc75b66
3 files changed
Lines changed: 107 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
141 | 146 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| |||
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
| |||
199 | 214 | | |
200 | 215 | | |
201 | 216 | | |
202 | | - | |
203 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
204 | 223 | | |
205 | 224 | | |
206 | 225 | | |
| |||
380 | 399 | | |
381 | 400 | | |
382 | 401 | | |
383 | | - | |
384 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
385 | 405 | | |
386 | 406 | | |
387 | 407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
221 | 225 | | |
222 | 226 | | |
223 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
0 commit comments