diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-05-28 00:41:57 +0000 |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-05-28 00:41:57 +0000 |
commit | 6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85 (patch) | |
tree | 0f97c3f8b3fac65680e880ec870796138af78faf /Lib/test/test_memoryio.py | |
parent | fc36e66af46957a65b12ab0087027727f8555aed (diff) | |
download | cpython-git-6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85.tar.gz |
Issue #20699: Document that “io” methods accept bytes-like objects
This matches the usage of ZipFile and BufferedWriter. This still requires
return values to be bytes() objects.
Also document and test that the write() methods should only access their
argument before they return.
Diffstat (limited to 'Lib/test/test_memoryio.py')
-rw-r--r-- | Lib/test/test_memoryio.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 812db4cfa8..55b693e564 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -399,7 +399,16 @@ class MemoryTestMixin: del __main__.PickleTestMemIO -class BytesIOMixin: +class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase): + # Test _pyio.BytesIO; class also inherited for testing C implementation + + UnsupportedOperation = pyio.UnsupportedOperation + + @staticmethod + def buftype(s): + return s.encode("ascii") + ioclass = pyio.BytesIO + EOF = b"" def test_getbuffer(self): memio = self.ioclass(b"1234567890") @@ -426,18 +435,6 @@ class BytesIOMixin: memio.close() self.assertRaises(ValueError, memio.getbuffer) - -class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, - BytesIOMixin, unittest.TestCase): - - UnsupportedOperation = pyio.UnsupportedOperation - - @staticmethod - def buftype(s): - return s.encode("ascii") - ioclass = pyio.BytesIO - EOF = b"" - def test_read1(self): buf = self.buftype("1234567890") memio = self.ioclass(buf) |