give exception a nice message (closes #22379)
Patch by Yongzhi Pan.
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index 0d07b91..f69255b 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -16,13 +16,10 @@
realresult
)
- def checkraises(self, exc, object, methodname, *args):
- self.assertRaises(
- exc,
- getattr(string, methodname),
- object,
- *args
- )
+ def checkraises(self, exc, obj, methodname, *args):
+ with self.assertRaises(exc) as cm:
+ getattr(string, methodname)(obj, *args)
+ self.assertNotEqual(cm.exception.message, '')
def checkcall(self, object, methodname, *args):
getattr(string, methodname)(object, *args)