MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_evil_repr1

Method test_evil_repr1

Lib/test/test_genericalias.py:247–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

245 self.assertEndsWith(repr(MyGeneric[[int, str]]), 'MyGeneric[[int, str]]')
246
247 def test_evil_repr1(self):
248 # gh-143635
249 class Zap:
250 def __init__(self, container):
251 self.container = container
252 def __getattr__(self, name):
253 if name == "__origin__":
254 self.container.clear()
255 return None
256 if name == "__args__":
257 return ()
258 raise AttributeError
259
260 params = []
261 params.append(Zap(params))
262 alias = GenericAlias(list, (params,))
263 repr_str = repr(alias)
264 self.assertTrue(repr_str.startswith("list[["), repr_str)
265
266 def test_evil_repr2(self):
267 class Zap:

Callers

nothing calls this directly

Calls 6

GenericAliasFunction · 0.90
ZapClass · 0.85
reprFunction · 0.85
assertTrueMethod · 0.80
appendMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected