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

Method test_evil_repr2

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

Source from the content-addressed store, hash-verified

264 self.assertTrue(repr_str.startswith("list[["), repr_str)
265
266 def test_evil_repr2(self):
267 class Zap:
268 def __init__(self, container):
269 self.container = container
270 def __getattr__(self, name):
271 if name == "__qualname__":
272 self.container.clear()
273 return "abcd"
274 if name == "__module__":
275 return None
276 raise AttributeError
277
278 params = []
279 params.append(Zap(params))
280 alias = GenericAlias(list, (params,))
281 repr_str = repr(alias)
282 self.assertTrue(repr_str.startswith("list[["), repr_str)
283
284 def test_evil_repr3(self):
285 # gh-143823

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