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

Method test_repr

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

Source from the content-addressed store, hash-verified

222 self.assertEqual(t.__parameters__, ())
223
224 def test_repr(self):
225 class MyList(list):
226 pass
227 class MyGeneric:
228 __class_getitem__ = classmethod(GenericAlias)
229
230 self.assertEqual(repr(list[str]), 'list[str]')
231 self.assertEqual(repr(list[()]), 'list[()]')
232 self.assertEqual(repr(tuple[int, ...]), 'tuple[int, ...]')
233 x1 = tuple[*tuple[int]]
234 self.assertEqual(repr(x1), 'tuple[*tuple[int]]')
235 x2 = tuple[*tuple[int, str]]
236 self.assertEqual(repr(x2), 'tuple[*tuple[int, str]]')
237 x3 = tuple[*tuple[int, ...]]
238 self.assertEqual(repr(x3), 'tuple[*tuple[int, ...]]')
239 self.assertEndsWith(repr(MyList[int]), '.BaseTest.test_repr.<locals>.MyList[int]')
240 self.assertEqual(repr(list[str]()), '[]') # instances should keep their normal repr
241
242 # gh-105488
243 self.assertEndsWith(repr(MyGeneric[int]), 'MyGeneric[int]')
244 self.assertEndsWith(repr(MyGeneric[[]]), 'MyGeneric[[]]')
245 self.assertEndsWith(repr(MyGeneric[[int, str]]), 'MyGeneric[[int, str]]')
246
247 def test_evil_repr1(self):
248 # gh-143635

Callers

nothing calls this directly

Calls 3

reprFunction · 0.85
assertEqualMethod · 0.45
assertEndsWithMethod · 0.45

Tested by

no test coverage detected