MCPcopy Index your code
hub / github.com/python/cpython / test_io_writer_protocol_allowed

Method test_io_writer_protocol_allowed

Lib/test/test_typing.py:4423–4438  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4421 self.assertNotIsInstance(A(), CustomReader)
4422
4423 def test_io_writer_protocol_allowed(self):
4424 @runtime_checkable
4425 class CustomWriter(io.Writer[bytes], Protocol):
4426 def close(self): ...
4427
4428 class A: pass
4429 class B:
4430 def write(self, b):
4431 pass
4432 def close(self):
4433 pass
4434
4435 self.assertIsSubclass(B, CustomWriter)
4436 self.assertIsInstance(B(), CustomWriter)
4437 self.assertNotIsSubclass(A, CustomWriter)
4438 self.assertNotIsInstance(A(), CustomWriter)
4439
4440 def test_builtin_protocol_allowlist(self):
4441 with self.assertRaises(TypeError):

Callers

nothing calls this directly

Calls 6

assertIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertNotIsSubclassMethod · 0.80
assertNotIsInstanceMethod · 0.80
BClass · 0.70
AClass · 0.70

Tested by

no test coverage detected