summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/string_tests.py7
-rw-r--r--Lib/test/test_descr.py4
-rw-r--r--Lib/test/test_unicode.py6
3 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 9e178ca..cb8900d 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -13,6 +13,7 @@ class Sequence:
class BadSeq1(Sequence):
def __init__(self): self.seq = [7, 'hello', 123]
+ def __str__(self): return '{0} {1} {2}'.format(*self.seq)
class BadSeq2(Sequence):
def __init__(self): self.seq = ['a', 'b', 'c']
@@ -987,19 +988,19 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('abc', 'a', 'join', ('abc',))
self.checkequal('z', 'a', 'join', UserList(['z']))
self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c'])
- self.checkraises(TypeError, '.', 'join', ['a', 'b', 3])
+ self.checkequal('a.b.3', '.', 'join', ['a', 'b', 3])
for i in [5, 25, 125]:
self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
['a' * i] * i)
self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
('a' * i,) * i)
- self.checkraises(TypeError, ' ', 'join', BadSeq1())
+ self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1())
self.checkequal('a b c', ' ', 'join', BadSeq2())
self.checkraises(TypeError, ' ', 'join')
self.checkraises(TypeError, ' ', 'join', 7)
- self.checkraises(TypeError, ' ', 'join', Sequence([7, 'hello', 123]))
+ self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()])
try:
def f():
yield 4 + ""
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 12bec1a..67ae239 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3238,10 +3238,6 @@ def strops():
except ValueError: pass
else: raise TestFailed("''.split('') doesn't raise ValueError")
- try: ''.join([0])
- except TypeError: pass
- else: raise TestFailed("''.join([0]) doesn't raise TypeError")
-
try: ''.rindex('5')
except ValueError: pass
else: raise TestFailed("''.rindex('5') doesn't raise ValueError")
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 64cca3f..1358419 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -178,6 +178,10 @@ class UnicodeTest(
def test_join(self):
string_tests.MixinStrUnicodeUserStringTest.test_join(self)
+ class MyWrapper:
+ def __init__(self, sval): self.sval = sval
+ def __str__(self): return self.sval
+
# mixed arguments
self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
@@ -186,6 +190,8 @@ class UnicodeTest(
self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz'))
+ self.checkequalnofix('1 2 foo', ' ', 'join', [1, 2, MyWrapper('foo')])
+ self.checkraises(TypeError, ' ', 'join', [1, 2, 3, bytes()])
def test_replace(self):
string_tests.CommonTest.test_replace(self)