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

Method test_repr

Lib/test/test_dataclasses/__init__.py:2632–2658  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2630
2631class TestRepr(unittest.TestCase):
2632 def test_repr(self):
2633 @dataclass
2634 class B:
2635 x: int
2636
2637 @dataclass
2638 class C(B):
2639 y: int = 10
2640
2641 o = C(4)
2642 self.assertEqual(repr(o), 'TestRepr.test_repr.<locals>.C(x=4, y=10)')
2643
2644 @dataclass
2645 class D(C):
2646 x: int = 20
2647 self.assertEqual(repr(D()), 'TestRepr.test_repr.<locals>.D(x=20, y=10)')
2648
2649 @dataclass
2650 class C:
2651 @dataclass
2652 class D:
2653 i: int
2654 @dataclass
2655 class E:
2656 pass
2657 self.assertEqual(repr(C.D(0)), 'TestRepr.test_repr.<locals>.C.D(i=0)')
2658 self.assertEqual(repr(C.E()), 'TestRepr.test_repr.<locals>.C.E()')
2659
2660 def test_no_repr(self):
2661 # Test a class with no __repr__ and repr=False.

Callers

nothing calls this directly

Calls 4

DMethod · 0.80
CClass · 0.70
DClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected