(self)
| 5854 | self.assertEqual(c.from_c, 'foo') |
| 5855 | |
| 5856 | def test_new_no_args(self): |
| 5857 | |
| 5858 | class A(Generic[T]): |
| 5859 | pass |
| 5860 | |
| 5861 | with self.assertRaises(TypeError): |
| 5862 | A('foo') |
| 5863 | |
| 5864 | class B: |
| 5865 | def __new__(cls): |
| 5866 | # call object |
| 5867 | obj = super().__new__(cls) |
| 5868 | obj.from_b = 'b' |
| 5869 | return obj |
| 5870 | |
| 5871 | # mro: C, A, Generic, B, object |
| 5872 | class C(A, B): |
| 5873 | def __init__(self, arg): |
| 5874 | self.arg = arg |
| 5875 | |
| 5876 | def __new__(cls, arg): |
| 5877 | # call A |
| 5878 | obj = super().__new__(cls) |
| 5879 | obj.from_c = 'c' |
| 5880 | return obj |
| 5881 | |
| 5882 | c = C('foo') |
| 5883 | self.assertEqual(c.arg, 'foo') |
| 5884 | self.assertEqual(c.from_b, 'b') |
| 5885 | self.assertEqual(c.from_c, 'c') |
| 5886 | |
| 5887 | def test_subclass_special_form(self): |
| 5888 | for obj in ( |
nothing calls this directly
no test coverage detected