MCPcopy
hub / github.com/python-attrs/attrs / test_custom_repr_works

Method test_custom_repr_works

tests/test_dunders.py:349–362  ·  view source on GitHub ↗

repr returns a sensible value for attributes with a custom repr callable.

(self)

Source from the content-addressed store, hash-verified

347 assert "C(a=1, b=2)" == repr(cls(1, 2))
348
349 def test_custom_repr_works(self):
350 """
351 repr returns a sensible value for attributes with a custom repr
352 callable.
353 """
354
355 def custom_repr(value):
356 return "foo:" + str(value)
357
358 @attr.s
359 class C:
360 a = attr.ib(repr=custom_repr)
361
362 assert "C(a=foo:1)" == repr(C(1))
363
364 def test_infinite_recursion(self):
365 """

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected