summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_userstring.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-09-28 16:56:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-09-28 16:56:42 (GMT)
commitc31f12d196455e916fcbcffc2cc2a3329abe70ed (patch)
treea76af66d38129fd6c50041f0878f24e8d07d512d /Lib/test/test_userstring.py
parent623ae294694dcf11eced4a9d24abf66a571a9d04 (diff)
downloadcpython-c31f12d196455e916fcbcffc2cc2a3329abe70ed.zip
cpython-c31f12d196455e916fcbcffc2cc2a3329abe70ed.tar.gz
cpython-c31f12d196455e916fcbcffc2cc2a3329abe70ed.tar.bz2
check that exception messages are not empty (#22379)
Patch by Yongzhi Pan.
Diffstat (limited to 'Lib/test/test_userstring.py')
-rw-r--r--Lib/test/test_userstring.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 34c629c..9bc8edd 100644
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -28,14 +28,12 @@ class UserStringTest(
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(str(cm.exception), '')
def checkcall(self, object, methodname, *args):
object = self.fixtype(object)