(self)
| 5747 | self.assertEqual(c.from_c, 'foo') |
| 5748 | |
| 5749 | def test_new_no_args(self): |
| 5750 | |
| 5751 | class A(Generic[T]): |
| 5752 | pass |
| 5753 | |
| 5754 | with self.assertRaises(TypeError): |
| 5755 | A('foo') |
| 5756 | |
| 5757 | class B: |
| 5758 | def __new__(cls): |
| 5759 | # call object |
| 5760 | obj = super().__new__(cls) |
| 5761 | obj.from_b = 'b' |
| 5762 | return obj |
| 5763 | |
| 5764 | # mro: C, A, Generic, B, object |
| 5765 | class C(A, B): |
| 5766 | def __init__(self, arg): |
| 5767 | self.arg = arg |
| 5768 | |
| 5769 | def __new__(cls, arg): |
| 5770 | # call A |
| 5771 | obj = super().__new__(cls) |
| 5772 | obj.from_c = 'c' |
| 5773 | return obj |
| 5774 | |
| 5775 | c = C('foo') |
| 5776 | self.assertEqual(c.arg, 'foo') |
| 5777 | self.assertEqual(c.from_b, 'b') |
| 5778 | self.assertEqual(c.from_c, 'c') |
| 5779 | |
| 5780 | def test_subclass_special_form(self): |
| 5781 | for obj in ( |
nothing calls this directly
no test coverage detected