MCPcopy Index your code
hub / github.com/ipython/ipython / test_named_tuple

Function test_named_tuple

tests/test_guarded_eval.py:193–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192
193def 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
215def test_dict():

Callers

nothing calls this directly

Calls 3

guarded_evalFunction · 0.90
GoodNamedTupleClass · 0.85
BadNamedTupleClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…