summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-04-06 06:37:17 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-04-06 06:37:17 (GMT)
commit152a19c6bd59b772660c8af050248a196bb6a848 (patch)
tree001af34753cc3f248610d31ca9c9d45011cdfcfd /Lib/test/test_bytes.py
parentb0660582cc9260022053c83dcfddd47891700147 (diff)
downloadcpython-152a19c6bd59b772660c8af050248a196bb6a848.zip
cpython-152a19c6bd59b772660c8af050248a196bb6a848.tar.gz
cpython-152a19c6bd59b772660c8af050248a196bb6a848.tar.bz2
Issue #26257: Eliminate buffer_tests.py and fix ByteArrayAsStringTest
ByteArrayAsStringTest.fixtype() was converting test data to bytes, not byte- array, therefore many of the test cases inherited in this class were not actually being run on the bytearray type. The tests in buffer_tests.py were redundant with methods in string_tests .MixinStrUnicodeUserStringTest and string_tests.CommonTest. These methods are now moved into string_tests.BaseTest, where they will also get run for bytes and bytearray. This change also moves test_additional_split(), test_additional_rsplit(), and test_strip() from CommonTest to BaseTest, meaning these tests are now run for bytes and bytearray. I plan to eliminate redundancies with existing tests in test_bytes.py soon.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 01ba5e5..6bcec23 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1,8 +1,7 @@
"""Unit tests for the bytes and bytearray types.
-XXX This is a mess. Common tests should be moved to buffer_tests.py,
-which itself ought to be unified with string_tests.py (and the latter
-should be modernized).
+XXX This is a mess. Common tests should be unified with string_tests.py (and
+the latter should be modernized).
"""
import os
@@ -16,7 +15,6 @@ import unittest
import test.support
import test.string_tests
-import test.buffer_tests
import test.list_tests
from test.support import bigaddrspacetest, MAX_Py_ssize_t
@@ -1480,8 +1478,7 @@ class AssortedBytesTest(unittest.TestCase):
# the rest that make sense (the code can be cleaned up to use modern
# unittest methods at the same time).
-class BytearrayPEP3137Test(unittest.TestCase,
- test.buffer_tests.MixinBytesBufferCommonTests):
+class BytearrayPEP3137Test(unittest.TestCase):
def marshal(self, x):
return bytearray(x)
@@ -1511,16 +1508,16 @@ class BytearrayPEP3137Test(unittest.TestCase,
class FixedStringTest(test.string_tests.BaseTest):
def fixtype(self, obj):
if isinstance(obj, str):
- return obj.encode("utf-8")
+ return self.type2test(obj.encode("utf-8"))
return super().fixtype(obj)
+ contains_bytes = True
+
class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase):
type2test = bytearray
- contains_bytes = True
class BytesAsStringTest(FixedStringTest, unittest.TestCase):
type2test = bytes
- contains_bytes = True
class SubclassTest: