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

Method test_io_reader_protocol_allowed

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

Source from the content-addressed store, hash-verified

4404 self.assertNotIsInstance(C(), ReleasableBuffer)
4405
4406 def test_io_reader_protocol_allowed(self):
4407 @runtime_checkable
4408 class CustomReader(io.Reader[bytes], Protocol):
4409 def close(self): ...
4410
4411 class A: pass
4412 class B:
4413 def read(self, sz=-1):
4414 return b""
4415 def close(self):
4416 pass
4417
4418 self.assertIsSubclass(B, CustomReader)
4419 self.assertIsInstance(B(), CustomReader)
4420 self.assertNotIsSubclass(A, CustomReader)
4421 self.assertNotIsInstance(A(), CustomReader)
4422
4423 def test_io_writer_protocol_allowed(self):
4424 @runtime_checkable

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