diff options
author | Barry Warsaw <barry@python.org> | 1997-01-06 22:46:07 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1997-01-06 22:46:07 (GMT) |
commit | da0e520bc025192135507081c48e0d4b31584e5a (patch) | |
tree | c92e3fb83b79e0d70c681a9e3b2be7461d7f5ab1 /Lib/test | |
parent | 9c5494a1b925d1040c82a1dc4478de510a1c88b5 (diff) | |
download | cpython-da0e520bc025192135507081c48e0d4b31584e5a.zip cpython-da0e520bc025192135507081c48e0d4b31584e5a.tar.gz cpython-da0e520bc025192135507081c48e0d4b31584e5a.tar.bz2 |
Added a couple of strop.join() tests for large lists and long items
within the lists (new output file to be checked in shortly).
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_strop.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_strop.py b/Lib/test/test_strop.py index 424cf52..efc98ff 100644 --- a/Lib/test/test_strop.py +++ b/Lib/test/test_strop.py @@ -1,13 +1,21 @@ +from test_support import verbose import strop, sys def test(name, input, output, *args): + if verbose: + print 'string.%s%s =? %s... ' % (name, (input,) + args, output), f = getattr(strop, name) try: value = apply(f, (input,) + args) except: value = sys.exc_type if value != output: + if verbose: + print 'no' print f, `input`, `output`, `value` + else: + if verbose: + print 'yes' test('atoi', " 1 ", 1) test('atoi', " 1x", ValueError) @@ -38,8 +46,19 @@ test('split', 'this is the split function', test('split', 'a|b|c|d', ['a', 'b', 'c', 'd'], '|') test('split', 'a|b|c|d', ['a', 'b', 'c|d'], '|', 2) +# join now works with any sequence type +class Sequence: + def __init__(self): self.seq = 'wxyz' + def __len__(self): return len(self.seq) + def __getitem__(self, i): return self.seq[i] + test('join', ['a', 'b', 'c', 'd'], 'a b c d') -test('join', ['a', 'b', 'c', 'd'], 'abcd', '') +test('join', ('a', 'b', 'c', 'd'), 'abcd', '') +test('join', Sequence(), 'w x y z') + +# try a few long ones +print strop.join(['x' * 100] * 100, ':') +print strop.join(('x' * 100,) * 100, ':') test('strip', ' hello ', 'hello') test('lstrip', ' hello ', 'hello ') |