(self)
| 1303 | #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000) |
| 1304 | |
| 1305 | def test_join(self): |
| 1306 | # join now works with any sequence type |
| 1307 | # moved here, because the argument order is |
| 1308 | # different in string.join |
| 1309 | self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) |
| 1310 | self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd')) |
| 1311 | self.checkequal('bd', '', 'join', ('', 'b', '', 'd')) |
| 1312 | self.checkequal('ac', '', 'join', ('a', '', 'c', '')) |
| 1313 | self.checkequal('w x y z', ' ', 'join', Sequence()) |
| 1314 | self.checkequal('abc', 'a', 'join', ('abc',)) |
| 1315 | self.checkequal('z', 'a', 'join', UserList(['z'])) |
| 1316 | self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c']) |
| 1317 | self.assertRaises(TypeError, '.'.join, ['a', 'b', 3]) |
| 1318 | for i in [5, 25, 125]: |
| 1319 | self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join', |
| 1320 | ['a' * i] * i) |
| 1321 | self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join', |
| 1322 | ('a' * i,) * i) |
| 1323 | |
| 1324 | class LiesAboutLengthSeq(Sequence): |
| 1325 | def __init__(self): self.seq = ['a', 'b', 'c'] |
| 1326 | def __len__(self): return 8 |
| 1327 | |
| 1328 | self.checkequal('a b c', ' ', 'join', LiesAboutLengthSeq()) |
| 1329 | |
| 1330 | self.checkraises(TypeError, ' ', 'join') |
| 1331 | self.checkraises(TypeError, ' ', 'join', None) |
| 1332 | self.checkraises(TypeError, ' ', 'join', 7) |
| 1333 | self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()]) |
| 1334 | try: |
| 1335 | def f(): |
| 1336 | yield 4 + "" |
| 1337 | self.fixtype(' ').join(f()) |
| 1338 | except TypeError as e: |
| 1339 | if '+' not in str(e): |
| 1340 | self.fail('join() ate exception message') |
| 1341 | else: |
| 1342 | self.fail('exception not raised') |
| 1343 | |
| 1344 | def test_formatting(self): |
| 1345 | self.checkequal('+hello+', '+%s+', '__mod__', 'hello') |
nothing calls this directly
no test coverage detected