(self)
| 2856 | |
| 2857 | class ProtocolTests(BaseTestCase): |
| 2858 | def test_basic_protocol(self): |
| 2859 | @runtime_checkable |
| 2860 | class P(Protocol): |
| 2861 | def meth(self): |
| 2862 | pass |
| 2863 | |
| 2864 | class C: pass |
| 2865 | |
| 2866 | class D: |
| 2867 | def meth(self): |
| 2868 | pass |
| 2869 | |
| 2870 | def f(): |
| 2871 | pass |
| 2872 | |
| 2873 | self.assertIsSubclass(D, P) |
| 2874 | self.assertIsInstance(D(), P) |
| 2875 | self.assertNotIsSubclass(C, P) |
| 2876 | self.assertNotIsInstance(C(), P) |
| 2877 | self.assertNotIsSubclass(types.FunctionType, P) |
| 2878 | self.assertNotIsInstance(f, P) |
| 2879 | |
| 2880 | def test_runtime_checkable_generic_non_protocol(self): |
| 2881 | # Make sure this doesn't raise AttributeError |
nothing calls this directly
no test coverage detected