MCPcopy Index your code
hub / github.com/python/cpython / test_repr

Method test_repr

Lib/test/test_functools.py:289–311  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

287 self.assertRaises(TypeError, tp, a=1, b=2)
288
289 def test_repr(self):
290 args = (object(), object())
291 args_repr = ', '.join(repr(a) for a in args)
292 kwargs = {'a': object(), 'b': object()}
293 kwargs_reprs = ['a={a!r}, b={b!r}'.format_map(kwargs),
294 'b={b!r}, a={a!r}'.format_map(kwargs)]
295 name = f"{self.partial.__module__}.{self.partial.__qualname__}"
296
297 f = self.partial(capture)
298 self.assertEqual(f'{name}({capture!r})', repr(f))
299
300 f = self.partial(capture, *args)
301 self.assertEqual(f'{name}({capture!r}, {args_repr})', repr(f))
302
303 f = self.partial(capture, **kwargs)
304 self.assertIn(repr(f),
305 [f'{name}({capture!r}, {kwargs_repr})'
306 for kwargs_repr in kwargs_reprs])
307
308 f = self.partial(capture, *args, **kwargs)
309 self.assertIn(repr(f),
310 [f'{name}({capture!r}, {args_repr}, {kwargs_repr})'
311 for kwargs_repr in kwargs_reprs])
312
313 def test_recursive_repr(self):
314 name = f"{self.partial.__module__}.{self.partial.__qualname__}"

Callers

nothing calls this directly

Calls 5

format_mapMethod · 0.80
partialMethod · 0.80
assertInMethod · 0.80
joinMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected