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
55import 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 :
0 commit comments