mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
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.
This commit is contained in:
parent
b0660582cc
commit
152a19c6bd
4 changed files with 54 additions and 229 deletions
|
@ -565,7 +565,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertTrue('\ud800\udc02' < '\ud84d\udc56')
|
||||
|
||||
def test_islower(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_islower(self)
|
||||
super().test_islower()
|
||||
self.checkequalnofix(False, '\u1FFc', 'islower')
|
||||
self.assertFalse('\u2167'.islower())
|
||||
self.assertTrue('\u2177'.islower())
|
||||
|
@ -580,7 +580,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertFalse('\U0001F46F'.islower())
|
||||
|
||||
def test_isupper(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_isupper(self)
|
||||
super().test_isupper()
|
||||
if not sys.platform.startswith('java'):
|
||||
self.checkequalnofix(False, '\u1FFc', 'isupper')
|
||||
self.assertTrue('\u2167'.isupper())
|
||||
|
@ -596,7 +596,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertFalse('\U0001F46F'.isupper())
|
||||
|
||||
def test_istitle(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_istitle(self)
|
||||
super().test_istitle()
|
||||
self.checkequalnofix(True, '\u1FFc', 'istitle')
|
||||
self.checkequalnofix(True, 'Greek \u1FFcitlecases ...', 'istitle')
|
||||
|
||||
|
@ -608,7 +608,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertFalse(ch.istitle(), '{!a} is not title'.format(ch))
|
||||
|
||||
def test_isspace(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_isspace(self)
|
||||
super().test_isspace()
|
||||
self.checkequalnofix(True, '\u2000', 'isspace')
|
||||
self.checkequalnofix(True, '\u200a', 'isspace')
|
||||
self.checkequalnofix(False, '\u2014', 'isspace')
|
||||
|
@ -618,13 +618,13 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertFalse(ch.isspace(), '{!a} is not space.'.format(ch))
|
||||
|
||||
def test_isalnum(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_isalnum(self)
|
||||
super().test_isalnum()
|
||||
for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
|
||||
'\U0001D7F6', '\U00011066', '\U000104A0', '\U0001F107']:
|
||||
self.assertTrue(ch.isalnum(), '{!a} is alnum.'.format(ch))
|
||||
|
||||
def test_isalpha(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_isalpha(self)
|
||||
super().test_isalpha()
|
||||
self.checkequalnofix(True, '\u1FFc', 'isalpha')
|
||||
# non-BMP, cased
|
||||
self.assertTrue('\U00010401'.isalpha())
|
||||
|
@ -654,7 +654,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertTrue(ch.isdecimal(), '{!a} is decimal.'.format(ch))
|
||||
|
||||
def test_isdigit(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_isdigit(self)
|
||||
super().test_isdigit()
|
||||
self.checkequalnofix(True, '\u2460', 'isdigit')
|
||||
self.checkequalnofix(False, '\xbc', 'isdigit')
|
||||
self.checkequalnofix(True, '\u0660', 'isdigit')
|
||||
|
@ -807,7 +807,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertEqual('A\u0345\u03a3'.capitalize(), 'A\u0345\u03c2')
|
||||
|
||||
def test_title(self):
|
||||
string_tests.MixinStrUnicodeUserStringTest.test_title(self)
|
||||
super().test_title()
|
||||
self.assertEqual('\U0001044F'.title(), '\U00010427')
|
||||
self.assertEqual('\U0001044F\U0001044F'.title(),
|
||||
'\U00010427\U0001044F')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue