summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryio.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-05-28 00:41:57 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-05-28 00:41:57 (GMT)
commit6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85 (patch)
tree0f97c3f8b3fac65680e880ec870796138af78faf /Lib/test/test_memoryio.py
parentfc36e66af46957a65b12ab0087027727f8555aed (diff)
downloadcpython-6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85.zip
cpython-6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85.tar.gz
cpython-6bb91f3b6e51352f91bcf785d3f6fe160ed2cd85.tar.bz2
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.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index 812db4c..55b693e 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)