Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_string.py @ 16413:8819867f14ef legacy-trunk
Patch derived from Trent's 101162: a Python/C API testing framework.
STILL NEEDS UNIX BUILD CHANGES.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Fri, 02 Feb 2001 05:57:15 +0000 |
| parents | e59b835ad89a |
| children | bb566f525f12 |
| rev | line source |
|---|---|
|
15966
e59b835ad89a
a bold attempt to fix things broken by MAL's verify patch: import
Fredrik Lundh <fredrik@pythonware.com>
parents:
15957
diff
changeset
|
1 from test_support import verbose, TestSkipped |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13353
diff
changeset
|
2 import string_tests |
|
10969
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
3 import string, sys |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
4 |
|
10987
e39a9f129163
Added a couple of endswith test cases for bugs reported by Timbot.
Barry Warsaw <barry@python.org>
parents:
10981
diff
changeset
|
5 # XXX: kludge... short circuit if strings don't have methods |
|
e39a9f129163
Added a couple of endswith test cases for bugs reported by Timbot.
Barry Warsaw <barry@python.org>
parents:
10981
diff
changeset
|
6 try: |
|
e39a9f129163
Added a couple of endswith test cases for bugs reported by Timbot.
Barry Warsaw <barry@python.org>
parents:
10981
diff
changeset
|
7 ''.join |
|
e39a9f129163
Added a couple of endswith test cases for bugs reported by Timbot.
Barry Warsaw <barry@python.org>
parents:
10981
diff
changeset
|
8 except AttributeError: |
|
13858
99f0413ef795
Raise 'TestSkipped' (from the test_support) module rather than 'ImportError'
Thomas Wouters <thomas@python.org>
parents:
13517
diff
changeset
|
9 raise TestSkipped |
|
10987
e39a9f129163
Added a couple of endswith test cases for bugs reported by Timbot.
Barry Warsaw <barry@python.org>
parents:
10981
diff
changeset
|
10 |
|
10969
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
11 def test(name, input, output, *args): |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
12 if verbose: |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
13 print 'string.%s%s =? %s... ' % (name, (input,) + args, output), |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
14 try: |
|
11992
1789fae5f074
Marc-Andre Lemburg: test script for Unicode implementation.
Guido van Rossum <guido@python.org>
parents:
10987
diff
changeset
|
15 # Prefer string methods over string module functions |
|
10974
51969fd73c4a
Harness can now test object methods directly, if they aren't available
Barry Warsaw <barry@python.org>
parents:
10969
diff
changeset
|
16 try: |
|
11992
1789fae5f074
Marc-Andre Lemburg: test script for Unicode implementation.
Guido van Rossum <guido@python.org>
parents:
10987
diff
changeset
|
17 f = getattr(input, name) |
|
1789fae5f074
Marc-Andre Lemburg: test script for Unicode implementation.
Guido van Rossum <guido@python.org>
parents:
10987
diff
changeset
|
18 value = apply(f, args) |
|
1789fae5f074
Marc-Andre Lemburg: test script for Unicode implementation.
Guido van Rossum <guido@python.org>
parents:
10987
diff
changeset
|
19 except AttributeError: |
|
10974
51969fd73c4a
Harness can now test object methods directly, if they aren't available
Barry Warsaw <barry@python.org>
parents:
10969
diff
changeset
|
20 f = getattr(string, name) |
|
51969fd73c4a
Harness can now test object methods directly, if they aren't available
Barry Warsaw <barry@python.org>
parents:
10969
diff
changeset
|
21 value = apply(f, (input,) + args) |
|
10969
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
22 except: |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
13858
diff
changeset
|
23 value = sys.exc_type |
|
10969
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
24 if value != output: |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
25 if verbose: |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
26 print 'no' |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
27 print f, `input`, `output`, `value` |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
28 else: |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
29 if verbose: |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
30 print 'yes' |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
31 |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13353
diff
changeset
|
32 string_tests.run_module_tests(test) |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13353
diff
changeset
|
33 string_tests.run_method_tests(test) |
|
10969
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
34 |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
35 string.whitespace |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
36 string.lowercase |
|
e1407d6320cb
Regression test for the new string methods.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
37 string.uppercase |
