diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 274616bf998dbc..7005321921cd5e 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -850,9 +850,10 @@ class BytesTest(BaseBytesTest, unittest.TestCase): type2test = bytes def test_getitem_error(self): + b = b'python' msg = "byte indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): - b'python'['a'] + b['a'] def test_buffer_is_readonly(self): fd = os.open(__file__, os.O_RDONLY) @@ -1040,14 +1041,15 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase): type2test = bytearray def test_getitem_error(self): + b = bytearray(b'python') msg = "bytearray indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): - bytearray(b'python')['a'] + b['a'] def test_setitem_error(self): + b = bytearray(b'python') msg = "bytearray indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): - b = bytearray(b'python') b['a'] = "python" def test_nohash(self): diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index 2c1848337b2d7f..730350ef0d139a 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -264,7 +264,8 @@ ... TypeError: dir() argument after * must be an iterable, not function - >>> None(*h) + >>> nothing = None + >>> nothing(*h) Traceback (most recent call last): ... TypeError: NoneType object argument after * must be an iterable, \ @@ -305,7 +306,7 @@ ... TypeError: dir() argument after ** must be a mapping, not function - >>> None(**h) + >>> nothing(**h) Traceback (most recent call last): ... TypeError: NoneType object argument after ** must be a mapping, \ diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py index 84c064f19f2ec2..0c6eeed9593038 100644 --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -8,9 +8,10 @@ class TupleTest(seq_tests.CommonTest): type2test = tuple def test_getitem_error(self): + t = () msg = "tuple indices must be integers or slices" with self.assertRaisesRegex(TypeError, msg): - ()['a'] + t['a'] def test_constructors(self): super().test_constructors()