repr returns a sensible value for attributes with a custom repr callable.
(self)
| 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 | """ |