Fix syntax warnings in tests introduced in bpo-15248. (GH-11932)

This commit is contained in:
Serhiy Storchaka 2019-02-19 13:49:09 +02:00 committed by GitHub
parent e7a4bb554e
commit 8e79e6e56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -852,9 +852,10 @@ class BytesTest(BaseBytesTest, unittest.TestCase):
type2test = bytes type2test = bytes
def test_getitem_error(self): def test_getitem_error(self):
b = b'python'
msg = "byte indices must be integers or slices" msg = "byte indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg): with self.assertRaisesRegex(TypeError, msg):
b'python'['a'] b['a']
def test_buffer_is_readonly(self): def test_buffer_is_readonly(self):
fd = os.open(__file__, os.O_RDONLY) fd = os.open(__file__, os.O_RDONLY)
@ -1042,14 +1043,15 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
type2test = bytearray type2test = bytearray
def test_getitem_error(self): def test_getitem_error(self):
b = bytearray(b'python')
msg = "bytearray indices must be integers or slices" msg = "bytearray indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg): with self.assertRaisesRegex(TypeError, msg):
bytearray(b'python')['a'] b['a']
def test_setitem_error(self): def test_setitem_error(self):
b = bytearray(b'python')
msg = "bytearray indices must be integers or slices" msg = "bytearray indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg): with self.assertRaisesRegex(TypeError, msg):
b = bytearray(b'python')
b['a'] = "python" b['a'] = "python"
def test_nohash(self): def test_nohash(self):

View File

@ -264,7 +264,8 @@ What about willful misconduct?
... ...
TypeError: dir() argument after * must be an iterable, not function TypeError: dir() argument after * must be an iterable, not function
>>> None(*h) >>> nothing = None
>>> nothing(*h)
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: NoneType object argument after * must be an iterable, \ TypeError: NoneType object argument after * must be an iterable, \
@ -305,7 +306,7 @@ not function
... ...
TypeError: dir() argument after ** must be a mapping, not function TypeError: dir() argument after ** must be a mapping, not function
>>> None(**h) >>> nothing(**h)
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: NoneType object argument after ** must be a mapping, \ TypeError: NoneType object argument after ** must be a mapping, \

View File

@ -19,9 +19,10 @@ class TupleTest(seq_tests.CommonTest):
type2test = tuple type2test = tuple
def test_getitem_error(self): def test_getitem_error(self):
t = ()
msg = "tuple indices must be integers or slices" msg = "tuple indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg): with self.assertRaisesRegex(TypeError, msg):
()['a'] t['a']
def test_constructors(self): def test_constructors(self):
super().test_constructors() super().test_constructors()