Skip to content

Commit a2f9388

Browse files
committed
merge 3.4 (#22379)
2 parents c081262 + c31f12d commit a2f9388

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

Lib/test/string_tests.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Common tests shared by test_str, test_unicode, test_userstring and test_string.
2+
Common tests shared by test_unicode, test_userstring and test_string.
33
"""
44

55
import unittest, string, sys, struct
@@ -79,11 +79,9 @@ class subtype(self.__class__.type2test):
7979
def checkraises(self, exc, obj, methodname, *args):
8080
obj = self.fixtype(obj)
8181
args = self.fixtype(args)
82-
self.assertRaises(
83-
exc,
84-
getattr(obj, methodname),
85-
*args
86-
)
82+
with self.assertRaises(exc) as cm:
83+
getattr(obj, methodname)(*args)
84+
self.assertNotEqual(str(cm.exception), '')
8785

8886
# call obj.method(*args) without any checks
8987
def checkcall(self, obj, methodname, *args):
@@ -1119,8 +1117,7 @@ def test_mul(self):
11191117
def test_join(self):
11201118
# join now works with any sequence type
11211119
# moved here, because the argument order is
1122-
# different in string.join (see the test in
1123-
# test.test_string.StringTest.test_join)
1120+
# different in string.join
11241121
self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
11251122
self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd'))
11261123
self.checkequal('bd', '', 'join', ('', 'b', '', 'd'))
@@ -1140,6 +1137,7 @@ def test_join(self):
11401137
self.checkequal('a b c', ' ', 'join', BadSeq2())
11411138

11421139
self.checkraises(TypeError, ' ', 'join')
1140+
self.checkraises(TypeError, ' ', 'join', None)
11431141
self.checkraises(TypeError, ' ', 'join', 7)
11441142
self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()])
11451143
try:

Lib/test/test_bytes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def test_join(self):
298298
seq = [b"abc"] * 1000
299299
expected = b"abc" + b".:abc" * 999
300300
self.assertEqual(dot_join(seq), expected)
301+
self.assertRaises(TypeError, self.type2test(b" ").join, None)
301302
# Error handling and cleanup when some item in the middle of the
302303
# sequence has the wrong type.
303304
with self.assertRaises(TypeError):

Lib/test/test_userstring.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ def checkequal(self, result, object, methodname, *args, **kwargs):
2828
realresult
2929
)
3030

31-
def checkraises(self, exc, object, methodname, *args):
32-
object = self.fixtype(object)
31+
def checkraises(self, exc, obj, methodname, *args):
32+
obj = self.fixtype(obj)
3333
# we don't fix the arguments, because UserString can't cope with it
34-
self.assertRaises(
35-
exc,
36-
getattr(object, methodname),
37-
*args
38-
)
34+
with self.assertRaises(exc) as cm:
35+
getattr(obj, methodname)(*args)
36+
self.assertNotEqual(str(cm.exception), '')
3937

4038
def checkcall(self, object, methodname, *args):
4139
object = self.fixtype(object)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ Mike Pall
10191019
Todd R. Palmer
10201020
Juan David Ibáñez Palomar
10211021
Jan Palus
1022+
Yongzhi Pan
10221023
Martin Panter
10231024
Mathias Panzenböck
10241025
M. Papillon

0 commit comments

Comments
 (0)