[Python-checkins] cpython (merge 3.5 -> default): Issue #19587: Merge test_bytes cleanup from 3.5
martin.panter
python-checkins at python.org
Mon Feb 1 06:09:44 EST 2016
https://hg.python.org/cpython/rev/8545a082fcaa
changeset: 100136:8545a082fcaa
parent: 100133:3b211ee66b82
parent: 100135:22c2dd04a3d3
user: Martin Panter <vadmium+py at gmail.com>
date: Tue Feb 02 10:54:10 2016 +0000
summary:
Issue #19587: Merge test_bytes cleanup from 3.5
files:
Lib/test/buffer_tests.py | 46 +--------------------------
Lib/test/string_tests.py | 10 ++---
Lib/test/test_bytes.py | 13 -------
3 files changed, 6 insertions(+), 63 deletions(-)
diff --git a/Lib/test/buffer_tests.py b/Lib/test/buffer_tests.py
--- a/Lib/test/buffer_tests.py
+++ b/Lib/test/buffer_tests.py
@@ -1,11 +1,8 @@
-# Tests that work for both bytes and buffer objects.
+# Tests that work for bytearray objects. Could be merged into string_tests.
# See PEP 3137.
-import struct
-import sys
-
class MixinBytesBufferCommonTests(object):
- """Tests that work for both bytes and buffer objects.
+ """Tests that work for bytearray objects.
See PEP 3137.
"""
@@ -88,16 +85,6 @@
self.assertRaises(TypeError, self.marshal(b'abc').isdigit, 42)
- def test_lower(self):
- self.assertEqual(b'hello', self.marshal(b'HeLLo').lower())
- self.assertEqual(b'hello', self.marshal(b'hello').lower())
- self.assertRaises(TypeError, self.marshal(b'hello').lower, 42)
-
- def test_upper(self):
- self.assertEqual(b'HELLO', self.marshal(b'HeLLo').upper())
- self.assertEqual(b'HELLO', self.marshal(b'HELLO').upper())
- self.assertRaises(TypeError, self.marshal(b'hello').upper, 42)
-
def test_capitalize(self):
self.assertEqual(b' hello ', self.marshal(b' hello ').capitalize())
self.assertEqual(b'Hello ', self.marshal(b'Hello ').capitalize())
@@ -153,35 +140,6 @@
self.assertRaises(TypeError, self.marshal(b'123').zfill)
- def test_expandtabs(self):
- self.assertEqual(b'abc\rab def\ng hi',
- self.marshal(b'abc\rab\tdef\ng\thi').expandtabs())
- self.assertEqual(b'abc\rab def\ng hi',
- self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8))
- self.assertEqual(b'abc\rab def\ng hi',
- self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(4))
- self.assertEqual(b'abc\r\nab def\ng hi',
- self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs())
- self.assertEqual(b'abc\r\nab def\ng hi',
- self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(8))
- self.assertEqual(b'abc\r\nab def\ng hi',
- self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(4))
- self.assertEqual(b'abc\r\nab\r\ndef\ng\r\nhi',
- self.marshal(b'abc\r\nab\r\ndef\ng\r\nhi').expandtabs(4))
- # check keyword args
- self.assertEqual(b'abc\rab def\ng hi',
- self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=8))
- self.assertEqual(b'abc\rab def\ng hi',
- self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=4))
-
- self.assertEqual(b' a\n b', self.marshal(b' \ta\n\tb').expandtabs(1))
-
- self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42)
- # This test is only valid when sizeof(int) == sizeof(void*) == 4.
- if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
- self.assertRaises(OverflowError,
- self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize)
-
def test_title(self):
self.assertEqual(b' Hello ', self.marshal(b' hello ').title())
self.assertEqual(b'Hello ', self.marshal(b'hello ').title())
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1,5 +1,5 @@
"""
-Common tests shared by test_unicode, test_userstring and test_string.
+Common tests shared by test_unicode, test_userstring and test_bytes.
"""
import unittest, string, sys, struct
@@ -686,8 +686,7 @@
class CommonTest(BaseTest):
# This testcase contains tests that can be used in all
- # stringlike classes. Currently this is str, unicode
- # UserString and the string module.
+ # stringlike classes. Currently this is str and UserString.
def test_hash(self):
# SF bug 1054139: += optimization was not invalidating cached hash value
@@ -857,8 +856,7 @@
class MixinStrUnicodeUserStringTest:
# additional tests that only work for
- # stringlike objects, i.e. str, unicode, UserString
- # (but not the string module)
+ # stringlike objects, i.e. str, UserString
def test_islower(self):
self.checkequal(False, '', 'islower')
@@ -1343,7 +1341,7 @@
class MixinStrUnicodeTest:
- # Additional tests that only work with str and unicode.
+ # Additional tests that only work with str.
def test_bug1001011(self):
# Make sure join returns a NEW object for single item sequences
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1562,24 +1562,11 @@
class FixedStringTest(test.string_tests.BaseTest):
-
def fixtype(self, obj):
if isinstance(obj, str):
return obj.encode("utf-8")
return super().fixtype(obj)
- # Currently the bytes containment testing uses a single integer
- # value. This may not be the final design, but until then the
- # bytes section with in a bytes containment not valid
- def test_contains(self):
- pass
- def test_expandtabs(self):
- pass
- def test_upper(self):
- pass
- def test_lower(self):
- pass
-
class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase):
type2test = bytearray
contains_bytes = True
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list