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