Commit c5c581d
fix(testing): make a2a_compat_shim resilient to wrong a2a-sdk in /tmp worktrees (#433)
* fix(testing): make a2a_compat_shim resilient to wrong a2a-sdk in /tmp worktrees
Attribute assignments like `pb.Role.user = pb.Role.ROLE_USER` at module
import time would raise AttributeError if a2a-sdk isn't at the pinned
version (>=1.0.1,<1.0.2), propagating through conftest.py's top-level
import and breaking pytest collection entirely. Agents running in fresh
/tmp worktrees with uninitialized environments hit this on PRs #391, #406, #407.
Two changes:
- `a2a_compat_shim.py`: introduce `_proto_alias()` helper that guards each
attribute alias independently with hasattr + a per-alias RuntimeWarning
(includes install command) rather than letting AttributeError propagate.
- `conftest.py`: wrap the shim import in try/except (ImportError|AttributeError)
with a fallback to None; update the autouse fixture to no-op when the shim
is unavailable, so collection always succeeds and only A2A tests fail.
https://claude.ai/code/session_01AnL37fUet4e3yXt9YBxd7a
* fix(testing): stacklevel=2 in _proto_alias + document _STATE_STRING_MAP asymmetry
stacklevel=2 makes the per-alias warning point at the _proto_alias() call
site in the module body (the useful diagnostic location) rather than at
the warnings.warn() line inside the helper.
Add a comment at _STATE_STRING_MAP explaining that any AttributeError from
the dict literal is caught by conftest.py's import guard, so the different
guard pattern is intentional and collection still succeeds.
https://claude.ai/code/session_01AnL37fUet4e3yXt9YBxd7a
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d897b62 commit c5c581d
2 files changed
Lines changed: 51 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
65 | 85 | | |
66 | 86 | | |
67 | 87 | | |
68 | 88 | | |
69 | | - | |
70 | | - | |
| 89 | + | |
| 90 | + | |
71 | 91 | | |
72 | 92 | | |
73 | 93 | | |
74 | 94 | | |
75 | 95 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
85 | 105 | | |
86 | 106 | | |
87 | 107 | | |
| |||
125 | 145 | | |
126 | 146 | | |
127 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
128 | 154 | | |
129 | 155 | | |
130 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
14 | 26 | | |
15 | 27 | | |
16 | 28 | | |
| |||
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
51 | | - | |
| 63 | + | |
52 | 64 | | |
53 | 65 | | |
54 | 66 | | |
| |||
0 commit comments