(self)
| 2978 | self.assertEqual(typing.get_protocol_members(NewGeneric), {'z'}) |
| 2979 | |
| 2980 | def test_no_instantiation(self): |
| 2981 | class P(Protocol): pass |
| 2982 | |
| 2983 | with self.assertRaises(TypeError): |
| 2984 | P() |
| 2985 | |
| 2986 | class C(P): pass |
| 2987 | |
| 2988 | self.assertIsInstance(C(), C) |
| 2989 | with self.assertRaises(TypeError): |
| 2990 | C(42) |
| 2991 | |
| 2992 | T = TypeVar('T') |
| 2993 | |
| 2994 | class PG(Protocol[T]): pass |
| 2995 | |
| 2996 | with self.assertRaises(TypeError): |
| 2997 | PG() |
| 2998 | with self.assertRaises(TypeError): |
| 2999 | PG[int]() |
| 3000 | with self.assertRaises(TypeError): |
| 3001 | PG[T]() |
| 3002 | |
| 3003 | class CG(PG[T]): pass |
| 3004 | |
| 3005 | self.assertIsInstance(CG[int](), CG) |
| 3006 | with self.assertRaises(TypeError): |
| 3007 | CG[int](42) |
| 3008 | |
| 3009 | def test_protocol_defining_init_does_not_get_overridden(self): |
| 3010 | # check that P.__init__ doesn't get clobbered |
nothing calls this directly
no test coverage detected