summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-09-28 16:57:22 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-09-28 16:57:22 (GMT)
commita2f93885b07bd3e78d803e83a4a8d893273e6642 (patch)
treeb905c9a223a4dddcbecc7405e4010d7f2aaec97b /Lib
parentc081262be6ceed935f56e9d21a9cefe02097223e (diff)
parentc31f12d196455e916fcbcffc2cc2a3329abe70ed (diff)
downloadcpython-a2f93885b07bd3e78d803e83a4a8d893273e6642.zip
cpython-a2f93885b07bd3e78d803e83a4a8d893273e6642.tar.gz
cpython-a2f93885b07bd3e78d803e83a4a8d893273e6642.tar.bz2
merge 3.4 (#22379)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/string_tests.py14
-rw-r--r--Lib/test/test_bytes.py1
-rw-r--r--Lib/test/test_userstring.py12
3 files changed, 12 insertions, 15 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 569bae1..6e26474 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1,5 +1,5 @@
"""
-Common tests shared by test_str, test_unicode, test_userstring and test_string.
+Common tests shared by test_unicode, test_userstring and test_string.
"""
import unittest, string, sys, struct
@@ -79,11 +79,9 @@ class BaseTest:
def checkraises(self, exc, obj, methodname, *args):
obj = self.fixtype(obj)
args = self.fixtype(args)
- self.assertRaises(
- exc,
- getattr(obj, methodname),
- *args
- )
+ with self.assertRaises(exc) as cm:
+ getattr(obj, methodname)(*args)
+ self.assertNotEqual(str(cm.exception), '')
# call obj.method(*args) without any checks
def checkcall(self, obj, methodname, *args):
@@ -1119,8 +1117,7 @@ class MixinStrUnicodeUserStringTest:
def test_join(self):
# join now works with any sequence type
# moved here, because the argument order is
- # different in string.join (see the test in
- # test.test_string.StringTest.test_join)
+ # different in string.join
self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd'))
self.checkequal('bd', '', 'join', ('', 'b', '', 'd'))
@@ -1140,6 +1137,7 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('a b c', ' ', 'join', BadSeq2())
self.checkraises(TypeError, ' ', 'join')
+ self.checkraises(TypeError, ' ', 'join', None)
self.checkraises(TypeError, ' ', 'join', 7)
self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()])
try:
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index db7c1b7..23a411e 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -298,6 +298,7 @@ class BaseBytesTest:
seq = [b"abc"] * 1000
expected = b"abc" + b".:abc" * 999
self.assertEqual(dot_join(seq), expected)
+ self.assertRaises(TypeError, self.type2test(b" ").join, None)
# Error handling and cleanup when some item in the middle of the
# sequence has the wrong type.
with self.assertRaises(TypeError):
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)