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)
commit86e0d5761177ef3fe7b50f7e9f235c70960d7834 (patch)
tree5514408463df9251de357a2383ed3b753bde59c1 /Lib/test/test_bytes.py
parentbc62af1bbe118aa678cb6fa4ecad40f7250b56de (diff)
downloadcpython-86e0d5761177ef3fe7b50f7e9f235c70960d7834.zip
cpython-86e0d5761177ef3fe7b50f7e9f235c70960d7834.tar.gz
cpython-86e0d5761177ef3fe7b50f7e9f235c70960d7834.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. Moved some tests into a new base class string_tests.NonStringModuleTest, and run them for bytearray.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index bdcb88a..99a5ef7 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
@@ -15,7 +14,6 @@ import tempfile
import unittest
import test.test_support
import test.string_tests
-import test.buffer_tests
if sys.flags.bytes_warning:
@@ -1030,8 +1028,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)
@@ -1053,12 +1050,10 @@ class BytearrayPEP3137Test(unittest.TestCase,
self.assertTrue(val is not newval,
expr+' returned val on a mutable object')
-class FixedStringTest(test.string_tests.BaseTest):
- def fixtype(self, obj):
- if isinstance(obj, str):
- return obj.encode("utf-8")
- return super(FixedStringTest, self).fixtype(obj)
+class ByteArrayAsStringTest(test.string_tests.CommonTest,
+ test.string_tests.NonStringModuleTest):
+ type2test = bytearray
# Currently the bytes containment testing uses a single integer
# value. This may not be the final design, but until then the
@@ -1076,10 +1071,6 @@ class FixedStringTest(test.string_tests.BaseTest):
pass
-class ByteArrayAsStringTest(FixedStringTest):
- type2test = bytearray
-
-
class ByteArraySubclass(bytearray):
pass
@@ -1160,7 +1151,6 @@ class ByteArraySubclassTest(unittest.TestCase):
def test_main():
#test.test_support.run_unittest(BytesTest)
#test.test_support.run_unittest(AssortedBytesTest)
- #test.test_support.run_unittest(BytesAsStringTest)
test.test_support.run_unittest(
ByteArrayTest,
ByteArrayAsStringTest,