give exception a nice message (closes #22379)
Patch by Yongzhi Pan.
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 51d8e8b..9cca14a 100644
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -28,14 +28,12 @@
realresult
)
- def checkraises(self, exc, object, methodname, *args):
- object = self.fixtype(object)
+ def checkraises(self, exc, obj, methodname, *args):
+ obj = self.fixtype(obj)
# we don't fix the arguments, because UserString can't cope with it
- self.assertRaises(
- exc,
- getattr(object, methodname),
- *args
- )
+ with self.assertRaises(exc) as cm:
+ getattr(obj, methodname)(*args)
+ self.assertNotEqual(cm.exception.message, '')
def checkcall(self, object, methodname, *args):
object = self.fixtype(object)