(self)
| 2630 | |
| 2631 | class 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. |
nothing calls this directly
no test coverage detected