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