MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_repr

Method test_repr

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected