cpython: 8545a082fcaa (original) (raw)
Mercurial > cpython
changeset 100136:8545a082fcaa
Issue #19587: Merge test_bytes cleanup from 3.5 [#19587]
Martin Panter vadmium+py@gmail.com | |
---|---|
date | Tue, 02 Feb 2016 10:54:10 +0000 |
parents | 3b211ee66b82(current diff)22c2dd04a3d3(diff) |
children | fb192db73ab1 |
files | Lib/test/test_bytes.py |
diffstat | 3 files changed, 6 insertions(+), 63 deletions(-)[+] [-] Lib/test/buffer_tests.py 46 Lib/test/string_tests.py 10 Lib/test/test_bytes.py 13 |
line wrap: on
line diff
--- 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 bytearray objects. See PEP 3137. """ @@ -88,16 +85,6 @@ class MixinBytesBufferCommonTests(object self.assertRaises(TypeError, self.marshal(b'abc').isdigit, 42)
- def test_lower(self):
self.assertEqual(b'hello', self.marshal(b'HeLLo').lower())[](#l1.22)
self.assertEqual(b'hello', self.marshal(b'hello').lower())[](#l1.23)
self.assertRaises(TypeError, self.marshal(b'hello').lower, 42)[](#l1.24)
- def test_upper(self):
self.assertEqual(b'HELLO', self.marshal(b'HeLLo').upper())[](#l1.27)
self.assertEqual(b'HELLO', self.marshal(b'HELLO').upper())[](#l1.28)
self.assertRaises(TypeError, self.marshal(b'hello').upper, 42)[](#l1.29)
- 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 @@ class MixinBytesBufferCommonTests(object self.assertRaises(TypeError, self.marshal(b'123').zfill)
- def test_expandtabs(self):
self.assertEqual(b'abc\rab def\ng hi',[](#l1.39)
self.marshal(b'abc\rab\tdef\ng\thi').expandtabs())[](#l1.40)
self.assertEqual(b'abc\rab def\ng hi',[](#l1.41)
self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8))[](#l1.42)
self.assertEqual(b'abc\rab def\ng hi',[](#l1.43)
self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(4))[](#l1.44)
self.assertEqual(b'abc\r\nab def\ng hi',[](#l1.45)
self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs())[](#l1.46)
self.assertEqual(b'abc\r\nab def\ng hi',[](#l1.47)
self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(8))[](#l1.48)
self.assertEqual(b'abc\r\nab def\ng hi',[](#l1.49)
self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(4))[](#l1.50)
self.assertEqual(b'abc\r\nab\r\ndef\ng\r\nhi',[](#l1.51)
self.marshal(b'abc\r\nab\r\ndef\ng\r\nhi').expandtabs(4))[](#l1.52)
# check keyword args[](#l1.53)
self.assertEqual(b'abc\rab def\ng hi',[](#l1.54)
self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=8))[](#l1.55)
self.assertEqual(b'abc\rab def\ng hi',[](#l1.56)
self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=4))[](#l1.57)
self.assertEqual(b' a\n b', self.marshal(b' \ta\n\tb').expandtabs(1))[](#l1.59)
self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42)[](#l1.61)
# This test is only valid when sizeof(int) == sizeof(void*) == 4.[](#l1.62)
if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:[](#l1.63)
self.assertRaises(OverflowError,[](#l1.64)
self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize)[](#l1.65)
- def test_title(self): self.assertEqual(b' Hello ', self.marshal(b' hello ').title()) self.assertEqual(b'Hello ', self.marshal(b'hello ').title())
--- 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 BaseTest: class CommonTest(BaseTest): # This testcase contains tests that can be used in all
def test_hash(self): # SF bug 1054139: += optimization was not invalidating cached hash value @@ -857,8 +856,7 @@ class CommonTest(BaseTest): class MixinStrUnicodeUserStringTest: # additional tests that only work for
def test_islower(self): self.checkequal(False, '', 'islower') @@ -1343,7 +1341,7 @@ class MixinStrUnicodeUserStringTest: class MixinStrUnicodeTest:
def test_bug1001011(self): # Make sure join returns a NEW object for single item sequences
--- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1562,24 +1562,11 @@ class BytearrayPEP3137Test(unittest.Test 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[](#l3.17)
- def test_expandtabs(self):
pass[](#l3.19)
- def test_upper(self):
pass[](#l3.21)
- def test_lower(self):
pass[](#l3.23)
- class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytearray contains_bytes = True