(self)
| 3036 | self.assertEqual(c.x, 1) |
| 3037 | |
| 3038 | def test_cannot_instantiate_abstract(self): |
| 3039 | @runtime_checkable |
| 3040 | class P(Protocol): |
| 3041 | @abc.abstractmethod |
| 3042 | def ameth(self) -> int: |
| 3043 | raise NotImplementedError |
| 3044 | |
| 3045 | class B(P): |
| 3046 | pass |
| 3047 | |
| 3048 | class C(B): |
| 3049 | def ameth(self) -> int: |
| 3050 | return 26 |
| 3051 | |
| 3052 | with self.assertRaises(TypeError): |
| 3053 | B() |
| 3054 | self.assertIsInstance(C(), P) |
| 3055 | |
| 3056 | def test_subprotocols_extending(self): |
| 3057 | class P1(Protocol): |
nothing calls this directly
no test coverage detected