()
| 191 | |
| 192 | |
| 193 | def test_named_tuple(): |
| 194 | class GoodNamedTuple(NamedTuple): |
| 195 | a: str |
| 196 | pass |
| 197 | |
| 198 | class BadNamedTuple(NamedTuple): |
| 199 | a: str |
| 200 | |
| 201 | def __getitem__(self, key): |
| 202 | return None |
| 203 | |
| 204 | good = GoodNamedTuple(a="x") |
| 205 | bad = BadNamedTuple(a="x") |
| 206 | |
| 207 | context = limited(data=good) |
| 208 | assert guarded_eval("data[0]", context) == "x" |
| 209 | |
| 210 | context = limited(data=bad) |
| 211 | with pytest.raises(GuardRejection): |
| 212 | guarded_eval("data[0]", context) |
| 213 | |
| 214 | |
| 215 | def test_dict(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…