mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-127647: Add typing.Reader and Writer protocols (#127648)
This commit is contained in:
parent
9c691500f9
commit
c6dd2348ca
9 changed files with 192 additions and 9 deletions
|
|
@ -4916,6 +4916,24 @@ class PySignalsTest(SignalsTest):
|
|||
test_reentrant_write_text = None
|
||||
|
||||
|
||||
class ProtocolsTest(unittest.TestCase):
|
||||
class MyReader:
|
||||
def read(self, sz=-1):
|
||||
return b""
|
||||
|
||||
class MyWriter:
|
||||
def write(self, b: bytes):
|
||||
pass
|
||||
|
||||
def test_reader_subclass(self):
|
||||
self.assertIsSubclass(MyReader, io.Reader[bytes])
|
||||
self.assertNotIsSubclass(str, io.Reader[bytes])
|
||||
|
||||
def test_writer_subclass(self):
|
||||
self.assertIsSubclass(MyWriter, io.Writer[bytes])
|
||||
self.assertNotIsSubclass(str, io.Writer[bytes])
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
tests = (CIOTest, PyIOTest, APIMismatchTest,
|
||||
CBufferedReaderTest, PyBufferedReaderTest,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue