Mercurial > cpython-lru_cache-weakref
annotate Lib/test/string_tests.py @ 48416:fb02fedfe647
Merged revisions 64677 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64677 | brett.cannon | 2008-07-02 14:52:42 -0700 (Wed, 02 Jul 2008) | 2 lines
Revert r64673 and instead just change the file encoding.
........
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Wed, 02 Jul 2008 22:06:12 +0000 |
| parents | 9c930a32cebb |
| children | 6403f1edecc1 |
| rev | line source |
|---|---|
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1 """ |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
2 Common tests shared by test_str, test_unicode, test_userstring and test_string. |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
3 """ |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
4 |
|
41716
00c02c4488ce
Merged revisions 55325-55327 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41642
diff
changeset
|
5 import unittest, string, sys, struct |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
45504
diff
changeset
|
6 from test import support |
|
45302
b1cb6b44b798
Move UserList to collections.
Raymond Hettinger <python@rcn.com>
parents:
44160
diff
changeset
|
7 from collections import UserList |
|
13527
07c31182f237
add more tests of string.join variants to run_method_tests
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13517
diff
changeset
|
8 |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
9 class Sequence: |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
10 def __init__(self, seq='wxyz'): self.seq = seq |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
11 def __len__(self): return len(self.seq) |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
12 def __getitem__(self, i): return self.seq[i] |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
13 |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
14 class BadSeq1(Sequence): |
|
40644
1c26505c1de6
Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents:
40587
diff
changeset
|
15 def __init__(self): self.seq = [7, 'hello', 123] |
|
43446
a7c48ab809ec
Patch # 1145 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
43100
diff
changeset
|
16 def __str__(self): return '{0} {1} {2}'.format(*self.seq) |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
17 |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
18 class BadSeq2(Sequence): |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
19 def __init__(self): self.seq = ['a', 'b', 'c'] |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
20 def __len__(self): return 8 |
|
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
21 |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
22 class BaseTest(unittest.TestCase): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
23 # These tests are for buffers of values (bytes) and not |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
24 # specific to character interpretation, used for bytes objects |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
25 # and various string implementations |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
26 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
27 # The type to be tested |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
28 # Change in subclasses to change the behaviour of fixtesttype() |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
29 type2test = None |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
30 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
31 # All tests pass their arguments to the testing methods |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
32 # as str objects. fixtesttype() can be used to propagate |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
33 # these arguments to the appropriate type |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
34 def fixtype(self, obj): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
35 if isinstance(obj, str): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
36 return self.__class__.type2test(obj) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
37 elif isinstance(obj, list): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
38 return [self.fixtype(x) for x in obj] |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
39 elif isinstance(obj, tuple): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
40 return tuple([self.fixtype(x) for x in obj]) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
41 elif isinstance(obj, dict): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
42 return dict([ |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
43 (self.fixtype(key), self.fixtype(value)) |
|
40809
f340cb045bf9
- PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;
Guido van Rossum <guido@python.org>
parents:
40644
diff
changeset
|
44 for (key, value) in obj.items() |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
45 ]) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
46 else: |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
47 return obj |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
48 |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
49 # check that obj.method(*args) returns result |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
50 def checkequal(self, result, obj, methodname, *args): |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
51 result = self.fixtype(result) |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
52 obj = self.fixtype(obj) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
53 args = self.fixtype(args) |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
54 realresult = getattr(obj, methodname)(*args) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
55 self.assertEqual( |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
56 result, |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
57 realresult |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
58 ) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
59 # if the original is returned make sure that |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
60 # this doesn't happen with subclasses |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
61 if obj is realresult: |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
62 try: |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
63 class subtype(self.__class__.type2test): |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
64 pass |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
65 except TypeError: |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
66 pass # Skip this if we can't subclass |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
67 else: |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
68 obj = subtype(obj) |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
69 realresult = getattr(obj, methodname)(*args) |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
70 self.assert_(obj is not realresult) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
71 |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
72 # check that obj.method(*args) raises exc |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
73 def checkraises(self, exc, obj, methodname, *args): |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
74 obj = self.fixtype(obj) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
75 args = self.fixtype(args) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
76 self.assertRaises( |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
77 exc, |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
78 getattr(obj, methodname), |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
79 *args |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
80 ) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
81 |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
82 # call obj.method(*args) without any checks |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
83 def checkcall(self, obj, methodname, *args): |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
84 obj = self.fixtype(obj) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
85 args = self.fixtype(args) |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
86 getattr(obj, methodname)(*args) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
87 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
88 def test_count(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
89 self.checkequal(3, 'aaa', 'count', 'a') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
90 self.checkequal(0, 'aaa', 'count', 'b') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
91 self.checkequal(3, 'aaa', 'count', 'a') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
92 self.checkequal(0, 'aaa', 'count', 'b') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
93 self.checkequal(3, 'aaa', 'count', 'a') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
94 self.checkequal(0, 'aaa', 'count', 'b') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
95 self.checkequal(0, 'aaa', 'count', 'b') |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
96 self.checkequal(2, 'aaa', 'count', 'a', 1) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
97 self.checkequal(0, 'aaa', 'count', 'a', 10) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
98 self.checkequal(1, 'aaa', 'count', 'a', -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
99 self.checkequal(3, 'aaa', 'count', 'a', -10) |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
100 self.checkequal(1, 'aaa', 'count', 'a', 0, 1) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
101 self.checkequal(3, 'aaa', 'count', 'a', 0, 10) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
102 self.checkequal(2, 'aaa', 'count', 'a', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
103 self.checkequal(0, 'aaa', 'count', 'a', 0, -10) |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
104 self.checkequal(3, 'aaa', 'count', '', 1) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
105 self.checkequal(1, 'aaa', 'count', '', 3) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
106 self.checkequal(0, 'aaa', 'count', '', 10) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
107 self.checkequal(2, 'aaa', 'count', '', -1) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
108 self.checkequal(4, 'aaa', 'count', '', -10) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
109 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
110 self.checkraises(TypeError, 'hello', 'count') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
111 self.checkraises(TypeError, 'hello', 'count', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
112 |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
113 # For a variety of combinations, |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
114 # verify that str.count() matches an equivalent function |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
115 # replacing all occurrences and then differencing the string lengths |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
116 charset = ['', 'a', 'b'] |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
117 digits = 7 |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
118 base = len(charset) |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
119 teststrings = set() |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
120 for i in range(base ** digits): |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
121 entry = [] |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
122 for j in range(digits): |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
123 i, m = divmod(i, base) |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
124 entry.append(charset[m]) |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
125 teststrings.add(''.join(entry)) |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
126 teststrings = [self.fixtype(ts) for ts in teststrings] |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
127 for i in teststrings: |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
128 n = len(i) |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
129 for j in teststrings: |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
130 r1 = i.count(j) |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
131 if j: |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
132 r2, rem = divmod(n - len(i.replace(j, self.fixtype(''))), |
|
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
133 len(j)) |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
134 else: |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
135 r2, rem = len(i)+1, 0 |
|
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
136 if rem or r1 != r2: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
137 self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i)) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
138 self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i)) |
|
34621
1edea4c2b011
* Beef-up tests for str.count().
Raymond Hettinger <python@rcn.com>
parents:
34620
diff
changeset
|
139 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
140 def test_find(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
141 self.checkequal(0, 'abcdefghiabc', 'find', 'abc') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
142 self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
143 self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
144 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
145 self.checkequal(0, 'abc', 'find', '', 0) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
146 self.checkequal(3, 'abc', 'find', '', 3) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
147 self.checkequal(-1, 'abc', 'find', '', 4) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
148 |
|
43897
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
149 # to check the ability to pass None as defaults |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
150 self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a') |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
151 self.checkequal(12, 'rrarrrrrrrrra', 'find', 'a', 4) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
152 self.checkequal(-1, 'rrarrrrrrrrra', 'find', 'a', 4, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
153 self.checkequal(12, 'rrarrrrrrrrra', 'find', 'a', 4, None) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
154 self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a', None, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
155 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
156 self.checkraises(TypeError, 'hello', 'find') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
157 self.checkraises(TypeError, 'hello', 'find', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
158 |
|
34620
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
159 # For a variety of combinations, |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
160 # verify that str.find() matches __contains__ |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
161 # and that the found substring is really at that location |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
162 charset = ['', 'a', 'b', 'c'] |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
163 digits = 5 |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
164 base = len(charset) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
165 teststrings = set() |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
166 for i in range(base ** digits): |
|
34620
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
167 entry = [] |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
168 for j in range(digits): |
|
34620
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
169 i, m = divmod(i, base) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
170 entry.append(charset[m]) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
171 teststrings.add(''.join(entry)) |
|
42911
cb28e14ee808
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42902
diff
changeset
|
172 teststrings = [self.fixtype(ts) for ts in teststrings] |
|
34620
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
173 for i in teststrings: |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
174 for j in teststrings: |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
175 loc = i.find(j) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
176 r1 = (loc != -1) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
177 r2 = j in i |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
178 if r1 != r2: |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
179 self.assertEqual(r1, r2) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
180 if loc != -1: |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
181 self.assertEqual(i[loc:loc+len(j)], j) |
|
556f6f1056a8
* Beef-up testing of str.__contains__() and str.find().
Raymond Hettinger <python@rcn.com>
parents:
33833
diff
changeset
|
182 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
183 def test_rfind(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
184 self.checkequal(9, 'abcdefghiabc', 'rfind', 'abc') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
185 self.checkequal(12, 'abcdefghiabc', 'rfind', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
186 self.checkequal(0, 'abcdefghiabc', 'rfind', 'abcd') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
187 self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
188 |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
189 self.checkequal(3, 'abc', 'rfind', '', 0) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
190 self.checkequal(3, 'abc', 'rfind', '', 3) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
191 self.checkequal(-1, 'abc', 'rfind', '', 4) |
|
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
192 |
|
43897
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
193 # to check the ability to pass None as defaults |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
194 self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a') |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
195 self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a', 4) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
196 self.checkequal(-1, 'rrarrrrrrrrra', 'rfind', 'a', 4, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
197 self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a', 4, None) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
198 self.checkequal( 2, 'rrarrrrrrrrra', 'rfind', 'a', None, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
199 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
200 self.checkraises(TypeError, 'hello', 'rfind') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
201 self.checkraises(TypeError, 'hello', 'rfind', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
202 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
203 def test_index(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
204 self.checkequal(0, 'abcdefghiabc', 'index', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
205 self.checkequal(3, 'abcdefghiabc', 'index', 'def') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
206 self.checkequal(0, 'abcdefghiabc', 'index', 'abc') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
207 self.checkequal(9, 'abcdefghiabc', 'index', 'abc', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
208 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
209 self.checkraises(ValueError, 'abcdefghiabc', 'index', 'hib') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
210 self.checkraises(ValueError, 'abcdefghiab', 'index', 'abc', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
211 self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', 8) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
212 self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
213 |
|
43897
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
214 # to check the ability to pass None as defaults |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
215 self.checkequal( 2, 'rrarrrrrrrrra', 'index', 'a') |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
216 self.checkequal(12, 'rrarrrrrrrrra', 'index', 'a', 4) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
217 self.checkraises(ValueError, 'rrarrrrrrrrra', 'index', 'a', 4, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
218 self.checkequal(12, 'rrarrrrrrrrra', 'index', 'a', 4, None) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
219 self.checkequal( 2, 'rrarrrrrrrrra', 'index', 'a', None, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
220 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
221 self.checkraises(TypeError, 'hello', 'index') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
222 self.checkraises(TypeError, 'hello', 'index', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
223 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
224 def test_rindex(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
225 self.checkequal(12, 'abcdefghiabc', 'rindex', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
226 self.checkequal(3, 'abcdefghiabc', 'rindex', 'def') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
227 self.checkequal(9, 'abcdefghiabc', 'rindex', 'abc') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
228 self.checkequal(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
229 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
230 self.checkraises(ValueError, 'abcdefghiabc', 'rindex', 'hib') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
231 self.checkraises(ValueError, 'defghiabc', 'rindex', 'def', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
232 self.checkraises(ValueError, 'defghiabc', 'rindex', 'abc', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
233 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, 8) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
234 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
235 |
|
43897
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
236 # to check the ability to pass None as defaults |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
237 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a') |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
238 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
239 self.checkraises(ValueError, 'rrarrrrrrrrra', 'rindex', 'a', 4, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
240 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4, None) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
241 self.checkequal( 2, 'rrarrrrrrrrra', 'rindex', 'a', None, 6) |
|
41f7c13ef161
Merged revisions 59005-59040 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
43777
diff
changeset
|
242 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
243 self.checkraises(TypeError, 'hello', 'rindex') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
244 self.checkraises(TypeError, 'hello', 'rindex', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
245 |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
246 def test_lower(self): |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
247 self.checkequal('hello', 'HeLLo', 'lower') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
248 self.checkequal('hello', 'hello', 'lower') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
249 self.checkraises(TypeError, 'hello', 'lower', 42) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
250 |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
251 def test_upper(self): |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
252 self.checkequal('HELLO', 'HeLLo', 'upper') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
253 self.checkequal('HELLO', 'HELLO', 'upper') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
254 self.checkraises(TypeError, 'hello', 'upper', 42) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
255 |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
256 def test_expandtabs(self): |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
257 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
258 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
259 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
260 self.checkequal('abc\r\nab def\ng hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
261 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
262 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
263 self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
264 self.checkequal(' a\n b', ' \ta\n\tb', 'expandtabs', 1) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
265 |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
266 self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
267 # This test is only valid when sizeof(int) == sizeof(void*) == 4. |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
268 if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4: |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
269 self.checkraises(OverflowError, |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
270 '\ta\n\tb', 'expandtabs', sys.maxsize) |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
271 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
272 def test_split(self): |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
273 # by a char |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
274 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
275 self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
276 self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
277 self.checkequal(['a', 'b', 'c|d'], 'a|b|c|d', 'split', '|', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
278 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
279 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
280 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
281 sys.maxsize-2) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
282 self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
283 self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
284 self.checkequal(['endcase ', ''], 'endcase |', 'split', '|') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
285 self.checkequal(['', ' startcase'], '| startcase', 'split', '|') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
286 self.checkequal(['', 'bothcase', ''], '|bothcase|', 'split', '|') |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
287 self.checkequal(['a', '', 'b\x00c\x00d'], 'a\x00\x00b\x00c\x00d', 'split', '\x00', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
288 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
289 self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
290 self.checkequal(['a']*15 +['a|a|a|a|a'], |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
291 ('a|'*20)[:-1], 'split', '|', 15) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
292 |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
293 # by string |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
294 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//') |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
295 self.checkequal(['a', 'b//c//d'], 'a//b//c//d', 'split', '//', 1) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
296 self.checkequal(['a', 'b', 'c//d'], 'a//b//c//d', 'split', '//', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
297 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
298 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
299 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
300 sys.maxsize-10) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
301 self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
302 self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
303 self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
304 self.checkequal(['', ' begincase'], 'test begincase', 'split', 'test') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
305 self.checkequal(['', ' bothcase ', ''], 'test bothcase test', |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
306 'split', 'test') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
307 self.checkequal(['a', 'bc'], 'abbbc', 'split', 'bb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
308 self.checkequal(['', ''], 'aaa', 'split', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
309 self.checkequal(['aaa'], 'aaa', 'split', 'aaa', 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
310 self.checkequal(['ab', 'ab'], 'abbaab', 'split', 'ba') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
311 self.checkequal(['aaaa'], 'aaaa', 'split', 'aab') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
312 self.checkequal([''], '', 'split', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
313 self.checkequal(['aa'], 'aa', 'split', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
314 self.checkequal(['A', 'bobb'], 'Abbobbbobb', 'split', 'bbobb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
315 self.checkequal(['A', 'B', ''], 'AbbobbBbbobb', 'split', 'bbobb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
316 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
317 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
318 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
319 self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4], |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
320 'split', 'BLAH', 18) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
321 |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
322 # argument type |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
323 self.checkraises(TypeError, 'hello', 'split', 42, 42, 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
324 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
325 # null case |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
326 self.checkraises(ValueError, 'hello', 'split', '') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
327 self.checkraises(ValueError, 'hello', 'split', '', 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
328 |
|
31199
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31021
diff
changeset
|
329 def test_rsplit(self): |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
330 # by a char |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
331 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|') |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
332 self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
333 self.checkequal(['a|b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
334 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
335 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
336 self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
337 sys.maxsize-100) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
338 self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
339 self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
340 self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
341 self.checkequal(['endcase ', ''], 'endcase |', 'rsplit', '|') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
342 self.checkequal(['', 'bothcase', ''], '|bothcase|', 'rsplit', '|') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
343 |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
344 self.checkequal(['a\x00\x00b', 'c', 'd'], 'a\x00\x00b\x00c\x00d', 'rsplit', '\x00', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
345 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
346 self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
347 self.checkequal(['a|a|a|a|a']+['a']*15, |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
348 ('a|'*20)[:-1], 'rsplit', '|', 15) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
349 |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
350 # by string |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
351 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//') |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
352 self.checkequal(['a//b//c', 'd'], 'a//b//c//d', 'rsplit', '//', 1) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
353 self.checkequal(['a//b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
354 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
355 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
356 self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
357 sys.maxsize-5) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
358 self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
359 self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2) |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
360 self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
361 self.checkequal(['endcase ', ''], 'endcase test', 'rsplit', 'test') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
362 self.checkequal(['', ' bothcase ', ''], 'test bothcase test', |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
363 'rsplit', 'test') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
364 self.checkequal(['ab', 'c'], 'abbbc', 'rsplit', 'bb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
365 self.checkequal(['', ''], 'aaa', 'rsplit', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
366 self.checkequal(['aaa'], 'aaa', 'rsplit', 'aaa', 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
367 self.checkequal(['ab', 'ab'], 'abbaab', 'rsplit', 'ba') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
368 self.checkequal(['aaaa'], 'aaaa', 'rsplit', 'aab') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
369 self.checkequal([''], '', 'rsplit', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
370 self.checkequal(['aa'], 'aa', 'rsplit', 'aaa') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
371 self.checkequal(['bbob', 'A'], 'bbobbbobbA', 'rsplit', 'bbobb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
372 self.checkequal(['', 'B', 'A'], 'bbobbBbbobbA', 'rsplit', 'bbobb') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
373 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
374 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
375 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
376 self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4], |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
377 'rsplit', 'BLAH', 18) |
|
31350
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
378 |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
379 # argument type |
|
eaa1a4b74328
[SF #866875] Add a specialized routine for one character
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31252
diff
changeset
|
380 self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42) |
|
31199
504943c89193
Add rsplit method for str and unicode builtin types.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31021
diff
changeset
|
381 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
382 # null case |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
383 self.checkraises(ValueError, 'hello', 'rsplit', '') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
384 self.checkraises(ValueError, 'hello', 'rsplit', '', 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
385 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
386 def test_replace(self): |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
387 EQ = self.checkequal |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
388 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
389 # Operations on the empty string |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
390 EQ("", "", "replace", "", "") |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
391 EQ("A", "", "replace", "", "A") |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
392 EQ("", "", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
393 EQ("", "", "replace", "A", "A") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
394 EQ("", "", "replace", "", "", 100) |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
395 EQ("", "", "replace", "", "", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
396 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
397 # interleave (from=="", 'to' gets inserted everywhere) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
398 EQ("A", "A", "replace", "", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
399 EQ("*A*", "A", "replace", "", "*") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
400 EQ("*1A*1", "A", "replace", "", "*1") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
401 EQ("*-#A*-#", "A", "replace", "", "*-#") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
402 EQ("*-A*-A*-", "AA", "replace", "", "*-") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
403 EQ("*-A*-A*-", "AA", "replace", "", "*-", -1) |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
404 EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
405 EQ("*-A*-A*-", "AA", "replace", "", "*-", 4) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
406 EQ("*-A*-A*-", "AA", "replace", "", "*-", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
407 EQ("*-A*-A", "AA", "replace", "", "*-", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
408 EQ("*-AA", "AA", "replace", "", "*-", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
409 EQ("AA", "AA", "replace", "", "*-", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
410 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
411 # single character deletion (from=="A", to=="") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
412 EQ("", "A", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
413 EQ("", "AAA", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
414 EQ("", "AAA", "replace", "A", "", -1) |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
415 EQ("", "AAA", "replace", "A", "", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
416 EQ("", "AAA", "replace", "A", "", 4) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
417 EQ("", "AAA", "replace", "A", "", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
418 EQ("A", "AAA", "replace", "A", "", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
419 EQ("AA", "AAA", "replace", "A", "", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
420 EQ("AAA", "AAA", "replace", "A", "", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
421 EQ("", "AAAAAAAAAA", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
422 EQ("BCD", "ABACADA", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
423 EQ("BCD", "ABACADA", "replace", "A", "", -1) |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
424 EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
425 EQ("BCD", "ABACADA", "replace", "A", "", 5) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
426 EQ("BCD", "ABACADA", "replace", "A", "", 4) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
427 EQ("BCDA", "ABACADA", "replace", "A", "", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
428 EQ("BCADA", "ABACADA", "replace", "A", "", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
429 EQ("BACADA", "ABACADA", "replace", "A", "", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
430 EQ("ABACADA", "ABACADA", "replace", "A", "", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
431 EQ("BCD", "ABCAD", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
432 EQ("BCD", "ABCADAA", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
433 EQ("BCD", "BCD", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
434 EQ("*************", "*************", "replace", "A", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
435 EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
436 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
437 # substring deletion (from=="the", to=="") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
438 EQ("", "the", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
439 EQ("ater", "theater", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
440 EQ("", "thethe", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
441 EQ("", "thethethethe", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
442 EQ("aaaa", "theatheatheathea", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
443 EQ("that", "that", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
444 EQ("thaet", "thaet", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
445 EQ("here and re", "here and there", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
446 EQ("here and re and re", "here and there and there", |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
447 "replace", "the", "", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
448 EQ("here and re and re", "here and there and there", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
449 "replace", "the", "", -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
450 EQ("here and re and re", "here and there and there", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
451 "replace", "the", "", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
452 EQ("here and re and re", "here and there and there", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
453 "replace", "the", "", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
454 EQ("here and re and there", "here and there and there", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
455 "replace", "the", "", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
456 EQ("here and there and there", "here and there and there", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
457 "replace", "the", "", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
458 EQ("here and re and re", "here and there and there", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
459 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
460 EQ("abc", "abc", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
461 EQ("abcdefg", "abcdefg", "replace", "the", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
462 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
463 # substring deletion (from=="bob", to=="") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
464 EQ("bob", "bbobob", "replace", "bob", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
465 EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
466 EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
467 EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
468 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
469 # single character replace in place (len(from)==len(to)==1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
470 EQ("Who goes there?", "Who goes there?", "replace", "o", "o") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
471 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
472 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
473 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
474 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
475 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
476 EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
477 EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
478 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
479 EQ("Who goes there?", "Who goes there?", "replace", "a", "q") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
480 EQ("who goes there?", "Who goes there?", "replace", "W", "w") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
481 EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
482 EQ("Who goes there!", "Who goes there?", "replace", "?", "!") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
483 EQ("Who goes there!!", "Who goes there??", "replace", "?", "!") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
484 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
485 EQ("Who goes there?", "Who goes there?", "replace", ".", "!") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
486 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
487 # substring replace in place (len(from)==len(to) > 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
488 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
489 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
490 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
491 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
492 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
493 EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
494 EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
495 EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
496 EQ("cobob", "bobob", "replace", "bob", "cob") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
497 EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
498 EQ("bobob", "bobob", "replace", "bot", "bot") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
499 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
500 # replace single character (len(from)==1, len(to)>1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
501 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
502 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1) |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
503 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
504 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
505 EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
506 EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
507 EQ("A----B----C----", "A.B.C.", "replace", ".", "----") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
508 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
509 EQ("Reykjavik", "Reykjavik", "replace", "q", "KK") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
510 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
511 # replace substring (len(from)>1, len(to)!=len(from)) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
512 EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
513 "replace", "spam", "ham") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
514 EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
515 "replace", "spam", "ham", sys.maxsize) |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
516 EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
517 "replace", "spam", "ham", -1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
518 EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
519 "replace", "spam", "ham", 4) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
520 EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
521 "replace", "spam", "ham", 3) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
522 EQ("ham, ham, eggs and spam", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
523 "replace", "spam", "ham", 2) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
524 EQ("ham, spam, eggs and spam", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
525 "replace", "spam", "ham", 1) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
526 EQ("spam, spam, eggs and spam", "spam, spam, eggs and spam", |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
527 "replace", "spam", "ham", 0) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
528 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
529 EQ("bobob", "bobobob", "replace", "bobob", "bob") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
530 EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
531 EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
532 |
|
42902
62874b34d95d
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42088
diff
changeset
|
533 # XXX Commented out. Is there any reason to support buffer objects |
|
62874b34d95d
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42088
diff
changeset
|
534 # as arguments for str.replace()? GvR |
|
43947
cbc8b3bd3157
Rename buffer -> bytearray.
Guido van Rossum <guido@python.org>
parents:
43897
diff
changeset
|
535 ## ba = bytearray('a') |
|
cbc8b3bd3157
Rename buffer -> bytearray.
Guido van Rossum <guido@python.org>
parents:
43897
diff
changeset
|
536 ## bb = bytearray('b') |
|
42902
62874b34d95d
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42088
diff
changeset
|
537 ## EQ("bbc", "abc", "replace", ba, bb) |
|
62874b34d95d
Changes in anticipation of stricter str vs. bytes enforcement.
Guido van Rossum <guido@python.org>
parents:
42088
diff
changeset
|
538 ## EQ("aac", "abc", "replace", bb, ba) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
539 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
540 # |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
541 self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
542 self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
543 self.checkequal('one@two@three!', 'one!two!three!', 'replace', '!', '@', 2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
544 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
545 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
546 self.checkequal('one!two!three!', 'one!two!three!', 'replace', '!', '@', 0) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
547 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
548 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
549 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@', 2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
550 self.checkequal('-a-b-c-', 'abc', 'replace', '', '-') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
551 self.checkequal('-a-b-c', 'abc', 'replace', '', '-', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
552 self.checkequal('abc', 'abc', 'replace', '', '-', 0) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
553 self.checkequal('', '', 'replace', '', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
554 self.checkequal('abc', 'abc', 'replace', 'ab', '--', 0) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
555 self.checkequal('abc', 'abc', 'replace', 'xy', '--') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
556 # Next three for SF bug 422088: [OSF1 alpha] string.replace(); died with |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
557 # MemoryError due to empty result (platform malloc issue when requesting |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
558 # 0 bytes). |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
559 self.checkequal('', '123', 'replace', '123', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
560 self.checkequal('', '123123', 'replace', '123', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
561 self.checkequal('x', '123x123', 'replace', '123', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
562 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
563 self.checkraises(TypeError, 'hello', 'replace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
564 self.checkraises(TypeError, 'hello', 'replace', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
565 self.checkraises(TypeError, 'hello', 'replace', 42, 'h') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
566 self.checkraises(TypeError, 'hello', 'replace', 'h', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
567 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
568 def test_replace_overflow(self): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
569 # Check for overflow checking on 32 bit machines |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
570 if sys.maxsize != 2147483647 or struct.calcsize("P") > 4: |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
571 return |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
572 A2_16 = "A" * (2**16) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
573 self.checkraises(OverflowError, A2_16, "replace", "", A2_16) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
574 self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
575 self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
576 |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
577 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
578 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
579 class CommonTest(BaseTest): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
580 # This testcase contains test that can be used in all |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
581 # stringlike classes. Currently this is str, unicode |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
582 # UserString and the string module. |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
583 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
584 def test_hash(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
585 # SF bug 1054139: += optimization was not invalidating cached hash value |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
586 a = self.type2test('DNSSEC') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
587 b = self.type2test('') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
588 for c in a: |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
589 b += c |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
590 hash(b) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
591 self.assertEqual(hash(a), hash(b)) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
592 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
593 def test_capitalize(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
594 self.checkequal(' hello ', ' hello ', 'capitalize') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
595 self.checkequal('Hello ', 'Hello ','capitalize') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
596 self.checkequal('Hello ', 'hello ','capitalize') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
597 self.checkequal('Aaaa', 'aaaa', 'capitalize') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
598 self.checkequal('Aaaa', 'AaAa', 'capitalize') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
599 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
600 self.checkraises(TypeError, 'hello', 'capitalize', 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
601 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
602 def test_lower(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
603 self.checkequal('hello', 'HeLLo', 'lower') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
604 self.checkequal('hello', 'hello', 'lower') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
605 self.checkraises(TypeError, 'hello', 'lower', 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
606 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
607 def test_upper(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
608 self.checkequal('HELLO', 'HeLLo', 'upper') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
609 self.checkequal('HELLO', 'HELLO', 'upper') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
610 self.checkraises(TypeError, 'hello', 'upper', 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
611 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
612 def test_expandtabs(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
613 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
614 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
615 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
616 self.checkequal('abc\r\nab def\ng hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
617 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
618 self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
619 self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
620 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
621 self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
622 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
623 def test_additional_split(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
624 self.checkequal(['this', 'is', 'the', 'split', 'function'], |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
625 'this is the split function', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
626 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
627 # by whitespace |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
628 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
629 self.checkequal(['a', 'b c d'], 'a b c d', 'split', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
630 self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
631 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
632 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
633 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
634 sys.maxsize-1) |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
635 self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
636 self.checkequal(['a b c d'], ' a b c d', 'split', None, 0) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
637 self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
638 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
639 self.checkequal([], ' ', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
640 self.checkequal(['a'], ' a ', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
641 self.checkequal(['a', 'b'], ' a b ', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
642 self.checkequal(['a', 'b '], ' a b ', 'split', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
643 self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
644 self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
645 self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
646 aaa = ' a '*20 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
647 self.checkequal(['a']*20, aaa, 'split') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
648 self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
649 self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
650 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
651 # mixed use of str and unicode |
|
41575
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
652 self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', ' ', 2) |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
653 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
654 def test_additional_rsplit(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
655 self.checkequal(['this', 'is', 'the', 'rsplit', 'function'], |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
656 'this is the rsplit function', 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
657 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
658 # by whitespace |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
659 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
660 self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
661 self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
662 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
663 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
664 self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, |
|
44160
9d152530910a
Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents:
43963
diff
changeset
|
665 sys.maxsize-20) |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
666 self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
667 self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
668 self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
669 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
670 self.checkequal([], ' ', 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
671 self.checkequal(['a'], ' a ', 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
672 self.checkequal(['a', 'b'], ' a b ', 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
673 self.checkequal([' a', 'b'], ' a b ', 'rsplit', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
674 self.checkequal([' a b','c'], ' a b c ', 'rsplit', |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
675 None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
676 self.checkequal([' a', 'b', 'c'], ' a b c ', 'rsplit', |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
677 None, 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
678 self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
679 aaa = ' a '*20 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
680 self.checkequal(['a']*20, aaa, 'rsplit') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
681 self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
682 self.checkequal([' a a'] + ['a']*18, aaa, 'rsplit', None, 18) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
683 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
684 # mixed use of str and unicode |
|
41575
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
685 self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', ' ', 2) |
|
41038
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
686 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
687 def test_strip(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
688 self.checkequal('hello', ' hello ', 'strip') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
689 self.checkequal('hello ', ' hello ', 'lstrip') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
690 self.checkequal(' hello', ' hello ', 'rstrip') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
691 self.checkequal('hello', 'hello', 'strip') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
692 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
693 # strip/lstrip/rstrip with None arg |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
694 self.checkequal('hello', ' hello ', 'strip', None) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
695 self.checkequal('hello ', ' hello ', 'lstrip', None) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
696 self.checkequal(' hello', ' hello ', 'rstrip', None) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
697 self.checkequal('hello', 'hello', 'strip', None) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
698 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
699 # strip/lstrip/rstrip with str arg |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
700 self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
701 self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
702 self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
703 self.checkequal('hello', 'hello', 'strip', 'xyz') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
704 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
705 self.checkraises(TypeError, 'hello', 'strip', 42, 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
706 self.checkraises(TypeError, 'hello', 'lstrip', 42, 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
707 self.checkraises(TypeError, 'hello', 'rstrip', 42, 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
708 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
709 def test_ljust(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
710 self.checkequal('abc ', 'abc', 'ljust', 10) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
711 self.checkequal('abc ', 'abc', 'ljust', 6) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
712 self.checkequal('abc', 'abc', 'ljust', 3) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
713 self.checkequal('abc', 'abc', 'ljust', 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
714 self.checkequal('abc*******', 'abc', 'ljust', 10, '*') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
715 self.checkraises(TypeError, 'abc', 'ljust') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
716 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
717 def test_rjust(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
718 self.checkequal(' abc', 'abc', 'rjust', 10) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
719 self.checkequal(' abc', 'abc', 'rjust', 6) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
720 self.checkequal('abc', 'abc', 'rjust', 3) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
721 self.checkequal('abc', 'abc', 'rjust', 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
722 self.checkequal('*******abc', 'abc', 'rjust', 10, '*') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
723 self.checkraises(TypeError, 'abc', 'rjust') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
724 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
725 def test_center(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
726 self.checkequal(' abc ', 'abc', 'center', 10) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
727 self.checkequal(' abc ', 'abc', 'center', 6) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
728 self.checkequal('abc', 'abc', 'center', 3) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
729 self.checkequal('abc', 'abc', 'center', 2) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
730 self.checkequal('***abc****', 'abc', 'center', 10, '*') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
731 self.checkraises(TypeError, 'abc', 'center') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
732 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
733 def test_swapcase(self): |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
734 self.checkequal('hEllO CoMPuTErS', 'HeLLo cOmpUteRs', 'swapcase') |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
735 |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
736 self.checkraises(TypeError, 'hello', 'swapcase', 42) |
|
efa0a761918c
Addendum of patch #1669633: additional tests for bytes methods.
Georg Brandl <georg@python.org>
parents:
40809
diff
changeset
|
737 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
738 def test_zfill(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
739 self.checkequal('123', '123', 'zfill', 2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
740 self.checkequal('123', '123', 'zfill', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
741 self.checkequal('0123', '123', 'zfill', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
742 self.checkequal('+123', '+123', 'zfill', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
743 self.checkequal('+123', '+123', 'zfill', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
744 self.checkequal('+0123', '+123', 'zfill', 5) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
745 self.checkequal('-123', '-123', 'zfill', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
746 self.checkequal('-123', '-123', 'zfill', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
747 self.checkequal('-0123', '-123', 'zfill', 5) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
748 self.checkequal('000', '', 'zfill', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
749 self.checkequal('34', '34', 'zfill', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
750 self.checkequal('0034', '34', 'zfill', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
751 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
752 self.checkraises(TypeError, '123', 'zfill') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
753 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
754 class MixinStrUnicodeUserStringTest: |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
755 # additional tests that only work for |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
756 # stringlike objects, i.e. str, unicode, UserString |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
757 # (but not the string module) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
758 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
759 def test_islower(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
760 self.checkequal(False, '', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
761 self.checkequal(True, 'a', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
762 self.checkequal(False, 'A', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
763 self.checkequal(False, '\n', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
764 self.checkequal(True, 'abc', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
765 self.checkequal(False, 'aBc', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
766 self.checkequal(True, 'abc\n', 'islower') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
767 self.checkraises(TypeError, 'abc', 'islower', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
768 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
769 def test_isupper(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
770 self.checkequal(False, '', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
771 self.checkequal(False, 'a', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
772 self.checkequal(True, 'A', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
773 self.checkequal(False, '\n', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
774 self.checkequal(True, 'ABC', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
775 self.checkequal(False, 'AbC', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
776 self.checkequal(True, 'ABC\n', 'isupper') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
777 self.checkraises(TypeError, 'abc', 'isupper', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
778 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
779 def test_istitle(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
780 self.checkequal(False, '', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
781 self.checkequal(False, 'a', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
782 self.checkequal(True, 'A', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
783 self.checkequal(False, '\n', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
784 self.checkequal(True, 'A Titlecased Line', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
785 self.checkequal(True, 'A\nTitlecased Line', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
786 self.checkequal(True, 'A Titlecased, Line', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
787 self.checkequal(False, 'Not a capitalized String', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
788 self.checkequal(False, 'Not\ta Titlecase String', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
789 self.checkequal(False, 'Not--a Titlecase String', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
790 self.checkequal(False, 'NOT', 'istitle') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
791 self.checkraises(TypeError, 'abc', 'istitle', 42) |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
792 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
793 def test_isspace(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
794 self.checkequal(False, '', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
795 self.checkequal(False, 'a', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
796 self.checkequal(True, ' ', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
797 self.checkequal(True, '\t', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
798 self.checkequal(True, '\r', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
799 self.checkequal(True, '\n', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
800 self.checkequal(True, ' \t\r\n', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
801 self.checkequal(False, ' \t\r\na', 'isspace') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
802 self.checkraises(TypeError, 'abc', 'isspace', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
803 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
804 def test_isalpha(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
805 self.checkequal(False, '', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
806 self.checkequal(True, 'a', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
807 self.checkequal(True, 'A', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
808 self.checkequal(False, '\n', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
809 self.checkequal(True, 'abc', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
810 self.checkequal(False, 'aBc123', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
811 self.checkequal(False, 'abc\n', 'isalpha') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
812 self.checkraises(TypeError, 'abc', 'isalpha', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
813 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
814 def test_isalnum(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
815 self.checkequal(False, '', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
816 self.checkequal(True, 'a', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
817 self.checkequal(True, 'A', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
818 self.checkequal(False, '\n', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
819 self.checkequal(True, '123abc456', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
820 self.checkequal(True, 'a1b3c', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
821 self.checkequal(False, 'aBc000 ', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
822 self.checkequal(False, 'abc\n', 'isalnum') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
823 self.checkraises(TypeError, 'abc', 'isalnum', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
824 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
825 def test_isdigit(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
826 self.checkequal(False, '', 'isdigit') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
827 self.checkequal(False, 'a', 'isdigit') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
828 self.checkequal(True, '0', 'isdigit') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
829 self.checkequal(True, '0123456789', 'isdigit') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
830 self.checkequal(False, '0123456789a', 'isdigit') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
831 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
832 self.checkraises(TypeError, 'abc', 'isdigit', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
833 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
834 def test_title(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
835 self.checkequal(' Hello ', ' hello ', 'title') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
836 self.checkequal('Hello ', 'hello ', 'title') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
837 self.checkequal('Hello ', 'Hello ', 'title') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
838 self.checkequal('Format This As Title String', "fOrMaT thIs aS titLe String", 'title') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
839 self.checkequal('Format,This-As*Title;String', "fOrMaT,thIs-aS*titLe;String", 'title', ) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
840 self.checkequal('Getint', "getInt", 'title') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
841 self.checkraises(TypeError, 'hello', 'title', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
842 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
843 def test_splitlines(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
844 self.checkequal(['abc', 'def', '', 'ghi'], "abc\ndef\n\rghi", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
845 self.checkequal(['abc', 'def', '', 'ghi'], "abc\ndef\n\r\nghi", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
846 self.checkequal(['abc', 'def', 'ghi'], "abc\ndef\r\nghi", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
847 self.checkequal(['abc', 'def', 'ghi'], "abc\ndef\r\nghi\n", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
848 self.checkequal(['abc', 'def', 'ghi', ''], "abc\ndef\r\nghi\n\r", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
849 self.checkequal(['', 'abc', 'def', 'ghi', ''], "\nabc\ndef\r\nghi\n\r", 'splitlines') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
850 self.checkequal(['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], "\nabc\ndef\r\nghi\n\r", 'splitlines', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
851 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
852 self.checkraises(TypeError, 'abc', 'splitlines', 42, 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
853 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
854 def test_startswith(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
855 self.checkequal(True, 'hello', 'startswith', 'he') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
856 self.checkequal(True, 'hello', 'startswith', 'hello') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
857 self.checkequal(False, 'hello', 'startswith', 'hello world') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
858 self.checkequal(True, 'hello', 'startswith', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
859 self.checkequal(False, 'hello', 'startswith', 'ello') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
860 self.checkequal(True, 'hello', 'startswith', 'ello', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
861 self.checkequal(True, 'hello', 'startswith', 'o', 4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
862 self.checkequal(False, 'hello', 'startswith', 'o', 5) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
863 self.checkequal(True, 'hello', 'startswith', '', 5) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
864 self.checkequal(False, 'hello', 'startswith', 'lo', 6) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
865 self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
866 self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3, 7) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
867 self.checkequal(False, 'helloworld', 'startswith', 'lowo', 3, 6) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
868 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
869 # test negative indices |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
870 self.checkequal(True, 'hello', 'startswith', 'he', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
871 self.checkequal(True, 'hello', 'startswith', 'he', -53, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
872 self.checkequal(False, 'hello', 'startswith', 'hello', 0, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
873 self.checkequal(False, 'hello', 'startswith', 'hello world', -1, -10) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
874 self.checkequal(False, 'hello', 'startswith', 'ello', -5) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
875 self.checkequal(True, 'hello', 'startswith', 'ello', -4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
876 self.checkequal(False, 'hello', 'startswith', 'o', -2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
877 self.checkequal(True, 'hello', 'startswith', 'o', -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
878 self.checkequal(True, 'hello', 'startswith', '', -3, -3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
879 self.checkequal(False, 'hello', 'startswith', 'lo', -9) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
880 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
881 self.checkraises(TypeError, 'hello', 'startswith') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
882 self.checkraises(TypeError, 'hello', 'startswith', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
883 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
884 # test tuple arguments |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
885 self.checkequal(True, 'hello', 'startswith', ('he', 'ha')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
886 self.checkequal(False, 'hello', 'startswith', ('lo', 'llo')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
887 self.checkequal(True, 'hello', 'startswith', ('hellox', 'hello')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
888 self.checkequal(False, 'hello', 'startswith', ()) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
889 self.checkequal(True, 'helloworld', 'startswith', ('hellowo', |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
890 'rld', 'lowo'), 3) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
891 self.checkequal(False, 'helloworld', 'startswith', ('hellowo', 'ello', |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
892 'rld'), 3) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
893 self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
894 self.checkequal(False, 'hello', 'startswith', ('he', 'hel'), 0, 1) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
895 self.checkequal(True, 'hello', 'startswith', ('he', 'hel'), 0, 2) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
896 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
897 self.checkraises(TypeError, 'hello', 'startswith', (42,)) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
898 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
899 def test_endswith(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
900 self.checkequal(True, 'hello', 'endswith', 'lo') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
901 self.checkequal(False, 'hello', 'endswith', 'he') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
902 self.checkequal(True, 'hello', 'endswith', '') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
903 self.checkequal(False, 'hello', 'endswith', 'hello world') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
904 self.checkequal(False, 'helloworld', 'endswith', 'worl') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
905 self.checkequal(True, 'helloworld', 'endswith', 'worl', 3, 9) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
906 self.checkequal(True, 'helloworld', 'endswith', 'world', 3, 12) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
907 self.checkequal(True, 'helloworld', 'endswith', 'lowo', 1, 7) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
908 self.checkequal(True, 'helloworld', 'endswith', 'lowo', 2, 7) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
909 self.checkequal(True, 'helloworld', 'endswith', 'lowo', 3, 7) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
910 self.checkequal(False, 'helloworld', 'endswith', 'lowo', 4, 7) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
911 self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, 8) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
912 self.checkequal(False, 'ab', 'endswith', 'ab', 0, 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
913 self.checkequal(False, 'ab', 'endswith', 'ab', 0, 0) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
914 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
915 # test negative indices |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
916 self.checkequal(True, 'hello', 'endswith', 'lo', -2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
917 self.checkequal(False, 'hello', 'endswith', 'he', -2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
918 self.checkequal(True, 'hello', 'endswith', '', -3, -3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
919 self.checkequal(False, 'hello', 'endswith', 'hello world', -10, -2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
920 self.checkequal(False, 'helloworld', 'endswith', 'worl', -6) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
921 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
922 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, 9) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
923 self.checkequal(True, 'helloworld', 'endswith', 'world', -7, 12) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
924 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -99, -3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
925 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -8, -3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
926 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -7, -3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
927 self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, -4) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
928 self.checkequal(False, 'helloworld', 'endswith', 'lowo', -8, -2) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
929 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
930 self.checkraises(TypeError, 'hello', 'endswith') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
931 self.checkraises(TypeError, 'hello', 'endswith', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
932 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
933 # test tuple arguments |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
934 self.checkequal(False, 'hello', 'endswith', ('he', 'ha')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
935 self.checkequal(True, 'hello', 'endswith', ('lo', 'llo')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
936 self.checkequal(True, 'hello', 'endswith', ('hellox', 'hello')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
937 self.checkequal(False, 'hello', 'endswith', ()) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
938 self.checkequal(True, 'helloworld', 'endswith', ('hellowo', |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
939 'rld', 'lowo'), 3) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
940 self.checkequal(False, 'helloworld', 'endswith', ('hellowo', 'ello', |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
941 'rld'), 3, -1) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
942 self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
943 self.checkequal(False, 'hello', 'endswith', ('he', 'hel'), 0, 1) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
944 self.checkequal(True, 'hello', 'endswith', ('he', 'hell'), 0, 4) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
945 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
946 self.checkraises(TypeError, 'hello', 'endswith', (42,)) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
947 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
948 def test___contains__(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
949 self.checkequal(True, '', '__contains__', '') # vereq('' in '', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
950 self.checkequal(True, 'abc', '__contains__', '') # vereq('' in 'abc', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
951 self.checkequal(False, 'abc', '__contains__', '\0') # vereq('\0' in 'abc', False) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
952 self.checkequal(True, '\0abc', '__contains__', '\0') # vereq('\0' in '\0abc', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
953 self.checkequal(True, 'abc\0', '__contains__', '\0') # vereq('\0' in 'abc\0', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
954 self.checkequal(True, '\0abc', '__contains__', 'a') # vereq('a' in '\0abc', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
955 self.checkequal(True, 'asdf', '__contains__', 'asdf') # vereq('asdf' in 'asdf', True) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
956 self.checkequal(False, 'asd', '__contains__', 'asdf') # vereq('asdf' in 'asd', False) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
957 self.checkequal(False, '', '__contains__', 'asdf') # vereq('asdf' in '', False) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
958 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
959 def test_subscript(self): |
|
41575
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
960 self.checkequal('a', 'abc', '__getitem__', 0) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
961 self.checkequal('c', 'abc', '__getitem__', -1) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
962 self.checkequal('a', 'abc', '__getitem__', 0) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
963 self.checkequal('abc', 'abc', '__getitem__', slice(0, 3)) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
964 self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000)) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
965 self.checkequal('a', 'abc', '__getitem__', slice(0, 1)) |
|
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
966 self.checkequal('', 'abc', '__getitem__', slice(0, 0)) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
967 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
968 self.checkraises(TypeError, 'abc', '__getitem__', 'def') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
969 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
970 def test_slice(self): |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
971 self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
972 self.checkequal('abc', 'abc', '__getitem__', slice(0, 3)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
973 self.checkequal('ab', 'abc', '__getitem__', slice(0, 2)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
974 self.checkequal('bc', 'abc', '__getitem__', slice(1, 3)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
975 self.checkequal('b', 'abc', '__getitem__', slice(1, 2)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
976 self.checkequal('', 'abc', '__getitem__', slice(2, 2)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
977 self.checkequal('', 'abc', '__getitem__', slice(1000, 1000)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
978 self.checkequal('', 'abc', '__getitem__', slice(2000, 1000)) |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
979 self.checkequal('', 'abc', '__getitem__', slice(2, 1)) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
980 |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
981 self.checkraises(TypeError, 'abc', '__getitem__', 'def') |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
982 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
983 def test_extended_getslice(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
984 # Test extended slicing by comparing with list slicing. |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
985 s = string.ascii_letters + string.digits |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
986 indices = (0, None, 1, 3, 41, -1, -2, -37) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
987 for start in indices: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
988 for stop in indices: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
989 # Skip step 0 (invalid) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
990 for step in indices[1:]: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
991 L = list(s)[start:stop:step] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
992 self.checkequal("".join(L), s, '__getitem__', |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
993 slice(start, stop, step)) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42911
diff
changeset
|
994 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
995 def test_mul(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
996 self.checkequal('', 'abc', '__mul__', -1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
997 self.checkequal('', 'abc', '__mul__', 0) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
998 self.checkequal('abc', 'abc', '__mul__', 1) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
999 self.checkequal('abcabcabc', 'abc', '__mul__', 3) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1000 self.checkraises(TypeError, 'abc', '__mul__') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1001 self.checkraises(TypeError, 'abc', '__mul__', '') |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35758
diff
changeset
|
1002 # XXX: on a 64-bit system, this doesn't raise an overflow error, |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35758
diff
changeset
|
1003 # but either raises a MemoryError, or succeeds (if you have 54TiB) |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35758
diff
changeset
|
1004 #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1005 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1006 def test_join(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1007 # join now works with any sequence type |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1008 # moved here, because the argument order is |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1009 # different in string.join (see the test in |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1010 # test.test_string.StringTest.test_join) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1011 self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1012 self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd')) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
1013 self.checkequal('bd', '', 'join', ('', 'b', '', 'd')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
1014 self.checkequal('ac', '', 'join', ('a', '', 'c', '')) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1015 self.checkequal('w x y z', ' ', 'join', Sequence()) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1016 self.checkequal('abc', 'a', 'join', ('abc',)) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1017 self.checkequal('z', 'a', 'join', UserList(['z'])) |
|
41620
6b7d1782a574
test_unicode.py passes again 9except for problems
Walter Dörwald <walter@livinglogic.de>
parents:
41575
diff
changeset
|
1018 self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c']) |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1019 self.assertRaises(TypeError, '.'.join, ['a', 'b', 3]) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1020 for i in [5, 25, 125]: |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1021 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join', |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1022 ['a' * i] * i) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1023 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join', |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1024 ('a' * i,) * i) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1025 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1026 #self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1()) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1027 self.checkequal('a b c', ' ', 'join', BadSeq2()) |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
1028 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1029 self.checkraises(TypeError, ' ', 'join') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1030 self.checkraises(TypeError, ' ', 'join', 7) |
|
43446
a7c48ab809ec
Patch # 1145 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
43100
diff
changeset
|
1031 self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()]) |
| 35758 | 1032 try: |
| 1033 def f(): | |
| 1034 yield 4 + "" | |
| 1035 self.fixtype(' ').join(f()) | |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
40450
diff
changeset
|
1036 except TypeError as e: |
| 35758 | 1037 if '+' not in str(e): |
| 1038 self.fail('join() ate exception message') | |
| 1039 else: | |
| 1040 self.fail('exception not raised') | |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1041 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1042 def test_formatting(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1043 self.checkequal('+hello+', '+%s+', '__mod__', 'hello') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1044 self.checkequal('+10+', '+%d+', '__mod__', 10) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1045 self.checkequal('a', "%c", '__mod__', "a") |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1046 self.checkequal('a', "%c", '__mod__', "a") |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1047 self.checkequal('"', "%c", '__mod__', 34) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1048 self.checkequal('$', "%c", '__mod__', 36) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1049 self.checkequal('10', "%d", '__mod__', 10) |
|
28478
8802de0da533
Fix PyString_Format() so that '%c' % u'a' returns u'a'
Walter Dörwald <walter@livinglogic.de>
parents:
28407
diff
changeset
|
1050 self.checkequal('\x7f', "%c", '__mod__', 0x7f) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1051 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1052 for ordinal in (-100, 0x200000): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1053 # unicode raises ValueError, str raises OverflowError |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1054 self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1055 |
|
45504
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1056 longvalue = sys.maxsize + 10 |
|
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1057 slongvalue = str(longvalue) |
|
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1058 if slongvalue[-1] in ("L","l"): slongvalue = slongvalue[:-1] |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1059 self.checkequal(' 42', '%3ld', '__mod__', 42) |
|
45504
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1060 self.checkequal('42', '%d', '__mod__', 42.0) |
|
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1061 self.checkequal(slongvalue, '%d', '__mod__', longvalue) |
|
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1062 self.checkcall('%d', '__mod__', float(longvalue)) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1063 self.checkequal('0042.00', '%07.2f', '__mod__', 42) |
|
30216
7ab1a41f16da
SF bug #795506: Wrong handling of string format code for float values.
Raymond Hettinger <python@rcn.com>
parents:
28774
diff
changeset
|
1064 self.checkequal('0042.00', '%07.2F', '__mod__', 42) |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1065 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1066 self.checkraises(TypeError, 'abc', '__mod__') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1067 self.checkraises(TypeError, '%(foo)s', '__mod__', 42) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1068 self.checkraises(TypeError, '%s%s', '__mod__', (42,)) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1069 self.checkraises(TypeError, '%c', '__mod__', (None,)) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1070 self.checkraises(ValueError, '%(foo', '__mod__', {}) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1071 self.checkraises(TypeError, '%(foo)s %(bar)s', '__mod__', ('foo', 42)) |
|
45504
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1072 self.checkraises(TypeError, '%d', '__mod__', "42") # not numeric |
|
1b6fb5699634
Merged revisions 61034-61036,61038-61048 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
45302
diff
changeset
|
1073 self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int/long conversion provided |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1074 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1075 # argument names with properly nested brackets are supported |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1076 self.checkequal('bar', '%((foo))s', '__mod__', {'(foo)': 'bar'}) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1077 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1078 # 100 is a magic number in PyUnicode_Format, this forces a resize |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1079 self.checkequal(103*'a'+'x', '%sx', '__mod__', 103*'a') |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1080 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1081 self.checkraises(TypeError, '%*s', '__mod__', ('foo', 'bar')) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1082 self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.)) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1083 self.checkraises(ValueError, '%10', '__mod__', (42,)) |
|
13517
4f110441db39
factor out test definitions to string_tests module
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
1084 |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1085 def test_floatformatting(self): |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1086 # float formatting |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
1087 for prec in range(100): |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1088 format = '%%.%if' % prec |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1089 value = 0.01 |
|
41642
a6eb6acfe04a
Merged revisions 55007-55179 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41620
diff
changeset
|
1090 for x in range(60): |
|
28009
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1091 value = value * 3.141592655 / 3.0 * 10.0 |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1092 # The formatfloat() code in stringobject.c and |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1093 # unicodeobject.c uses a 120 byte buffer and switches from |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1094 # 'f' formatting to 'g' at precision 50, so we expect |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1095 # OverflowErrors for the ranges x < 50 and prec >= 67. |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1096 if x < 50 and prec >= 67: |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1097 self.checkraises(OverflowError, format, "__mod__", value) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1098 else: |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1099 self.checkcall(format, "__mod__", value) |
|
fe10ece8ba68
Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents:
26625
diff
changeset
|
1100 |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1101 def test_inplace_rewrites(self): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1102 # Check that strings don't copy and modify cached single-character strings |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1103 self.checkequal('a', 'A', 'lower') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1104 self.checkequal(True, 'A', 'isupper') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1105 self.checkequal('A', 'a', 'upper') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1106 self.checkequal(True, 'a', 'islower') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1107 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1108 self.checkequal('a', 'A', 'replace', 'A', 'a') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1109 self.checkequal(True, 'A', 'isupper') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1110 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1111 self.checkequal('A', 'a', 'capitalize') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1112 self.checkequal(True, 'a', 'islower') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1113 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1114 self.checkequal('A', 'a', 'swapcase') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1115 self.checkequal(True, 'a', 'islower') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1116 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1117 self.checkequal('A', 'a', 'title') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1118 self.checkequal(True, 'a', 'islower') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1119 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1120 def test_partition(self): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1121 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1122 self.checkequal(('this is the par', 'ti', 'tion method'), |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1123 'this is the partition method', 'partition', 'ti') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1124 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1125 # from raymond's original specification |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1126 S = 'http://www.python.org' |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1127 self.checkequal(('http', '://', 'www.python.org'), S, 'partition', '://') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1128 self.checkequal(('http://www.python.org', '', ''), S, 'partition', '?') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1129 self.checkequal(('', 'http://', 'www.python.org'), S, 'partition', 'http://') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1130 self.checkequal(('http://www.python.', 'org', ''), S, 'partition', 'org') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1131 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1132 self.checkraises(ValueError, S, 'partition', '') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1133 self.checkraises(TypeError, S, 'partition', None) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1134 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1135 def test_rpartition(self): |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1136 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1137 self.checkequal(('this is the rparti', 'ti', 'on method'), |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1138 'this is the rpartition method', 'rpartition', 'ti') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1139 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1140 # from raymond's original specification |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1141 S = 'http://www.python.org' |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1142 self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1143 self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1144 self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1145 self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1146 |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1147 self.checkraises(ValueError, S, 'rpartition', '') |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1148 self.checkraises(TypeError, S, 'rpartition', None) |
|
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
36501
diff
changeset
|
1149 |
|
33298
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1150 |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1151 class MixinStrUnicodeTest: |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1152 # Additional tests that only work with str and unicode. |
|
33298
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1153 |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1154 def test_bug1001011(self): |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1155 # Make sure join returns a NEW object for single item sequences |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1156 # involving a subclass. |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1157 # Make sure that it is of the appropriate type. |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1158 # Check the optimisation still occurs for standard objects. |
|
33298
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1159 t = self.type2test |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1160 class subclass(t): |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1161 pass |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1162 s1 = subclass("abcd") |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1163 s2 = t().join([s1]) |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1164 self.assert_(s1 is not s2) |
|
a37ae7dba814
Move test_bug1001011() to string_tests.MixinStrUnicodeTest so that
Walter Dörwald <walter@livinglogic.de>
parents:
32951
diff
changeset
|
1165 self.assert_(type(s2) is t) |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1166 |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1167 s1 = t("abcd") |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1168 s2 = t().join([s1]) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1169 self.assert_(s1 is s2) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1170 |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1171 # Should also test mixed-type join. |
|
41575
beacf40b5960
Rip out all the u"..." literals and calls to unicode().
Guido van Rossum <guido@python.org>
parents:
41554
diff
changeset
|
1172 if t is str: |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1173 s1 = subclass("abcd") |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1174 s2 = "".join([s1]) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1175 self.assert_(s1 is not s2) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1176 self.assert_(type(s2) is t) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1177 |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1178 s1 = t("abcd") |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1179 s2 = "".join([s1]) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1180 self.assert_(s1 is s2) |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1181 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1182 ## elif t is str8: |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1183 ## s1 = subclass("abcd") |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1184 ## s2 = "".join([s1]) |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1185 ## self.assert_(s1 is not s2) |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1186 ## self.assert_(type(s2) is str) # promotes! |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1187 |
|
43777
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1188 ## s1 = t("abcd") |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1189 ## s2 = "".join([s1]) |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1190 ## self.assert_(s1 is not s2) |
|
0d462d789b18
Merging the py3k-pep3137 branch back into the py3k branch.
Guido van Rossum <guido@python.org>
parents:
43604
diff
changeset
|
1191 ## self.assert_(type(s2) is str) # promotes! |
|
33305
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1192 |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1193 else: |
|
78b578c46770
test_bug1001011(): Verify that
Tim Peters <tim.peters@gmail.com>
parents:
33298
diff
changeset
|
1194 self.fail("unexpected type for MixinStrUnicodeTest %r" % t) |
