Back to index

python3.2  3.2.2
Public Member Functions
test.string_tests.MixinStrUnicodeUserStringTest Class Reference
Inheritance diagram for test.string_tests.MixinStrUnicodeUserStringTest:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_islower
def test_isupper
def test_istitle
def test_isspace
def test_isalpha
def test_isalnum
def test_isdigit
def test_title
def test_splitlines
def test_startswith
def test_endswith
def test___contains__
def test_subscript
def test_slice
def test_extended_getslice
def test_mul
def test_join
def test_formatting
def test_floatformatting
def test_inplace_rewrites
def test_partition
def test_rpartition
def test_none_arguments
def test_find_etc_raise_correct_error_messages

Detailed Description

Definition at line 798 of file string_tests.py.


Member Function Documentation

Definition at line 992 of file string_tests.py.

00992 
00993     def test___contains__(self):
00994         self.checkequal(True, '', '__contains__', '')
00995         self.checkequal(True, 'abc', '__contains__', '')
00996         self.checkequal(False, 'abc', '__contains__', '\0')
00997         self.checkequal(True, '\0abc', '__contains__', '\0')
00998         self.checkequal(True, 'abc\0', '__contains__', '\0')
00999         self.checkequal(True, '\0abc', '__contains__', 'a')
01000         self.checkequal(True, 'asdf', '__contains__', 'asdf')
01001         self.checkequal(False, 'asd', '__contains__', 'asdf')
01002         self.checkequal(False, '', '__contains__', 'asdf')

Here is the call graph for this function:

Definition at line 943 of file string_tests.py.

00943 
00944     def test_endswith(self):
00945         self.checkequal(True, 'hello', 'endswith', 'lo')
00946         self.checkequal(False, 'hello', 'endswith', 'he')
00947         self.checkequal(True, 'hello', 'endswith', '')
00948         self.checkequal(False, 'hello', 'endswith', 'hello world')
00949         self.checkequal(False, 'helloworld', 'endswith', 'worl')
00950         self.checkequal(True, 'helloworld', 'endswith', 'worl', 3, 9)
00951         self.checkequal(True, 'helloworld', 'endswith', 'world', 3, 12)
00952         self.checkequal(True, 'helloworld', 'endswith', 'lowo', 1, 7)
00953         self.checkequal(True, 'helloworld', 'endswith', 'lowo', 2, 7)
00954         self.checkequal(True, 'helloworld', 'endswith', 'lowo', 3, 7)
00955         self.checkequal(False, 'helloworld', 'endswith', 'lowo', 4, 7)
00956         self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, 8)
00957         self.checkequal(False, 'ab', 'endswith', 'ab', 0, 1)
00958         self.checkequal(False, 'ab', 'endswith', 'ab', 0, 0)
00959 
00960         # test negative indices
00961         self.checkequal(True, 'hello', 'endswith', 'lo', -2)
00962         self.checkequal(False, 'hello', 'endswith', 'he', -2)
00963         self.checkequal(True, 'hello', 'endswith', '', -3, -3)
00964         self.checkequal(False, 'hello', 'endswith', 'hello world', -10, -2)
00965         self.checkequal(False, 'helloworld', 'endswith', 'worl', -6)
00966         self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, -1)
00967         self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, 9)
00968         self.checkequal(True, 'helloworld', 'endswith', 'world', -7, 12)
00969         self.checkequal(True, 'helloworld', 'endswith', 'lowo', -99, -3)
00970         self.checkequal(True, 'helloworld', 'endswith', 'lowo', -8, -3)
00971         self.checkequal(True, 'helloworld', 'endswith', 'lowo', -7, -3)
00972         self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, -4)
00973         self.checkequal(False, 'helloworld', 'endswith', 'lowo', -8, -2)
00974 
00975         self.checkraises(TypeError, 'hello', 'endswith')
00976         self.checkraises(TypeError, 'hello', 'endswith', 42)
00977 
00978         # test tuple arguments
00979         self.checkequal(False, 'hello', 'endswith', ('he', 'ha'))
00980         self.checkequal(True, 'hello', 'endswith', ('lo', 'llo'))
00981         self.checkequal(True, 'hello', 'endswith', ('hellox', 'hello'))
00982         self.checkequal(False, 'hello', 'endswith', ())
00983         self.checkequal(True, 'helloworld', 'endswith', ('hellowo',
00984                                                            'rld', 'lowo'), 3)
00985         self.checkequal(False, 'helloworld', 'endswith', ('hellowo', 'ello',
00986                                                             'rld'), 3, -1)
00987         self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1)
00988         self.checkequal(False, 'hello', 'endswith', ('he', 'hel'), 0, 1)
00989         self.checkequal(True, 'hello', 'endswith', ('he', 'hell'), 0, 4)
00990 
00991         self.checkraises(TypeError, 'hello', 'endswith', (42,))

Here is the call graph for this function:

Definition at line 1027 of file string_tests.py.

01027 
01028     def test_extended_getslice(self):
01029         # Test extended slicing by comparing with list slicing.
01030         s = string.ascii_letters + string.digits
01031         indices = (0, None, 1, 3, 41, -1, -2, -37)
01032         for start in indices:
01033             for stop in indices:
01034                 # Skip step 0 (invalid)
01035                 for step in indices[1:]:
01036                     L = list(s)[start:stop:step]
01037                     self.checkequal("".join(L), s, '__getitem__',
01038                                     slice(start, stop, step))

Here is the call graph for this function:

Definition at line 1224 of file string_tests.py.

01224 
01225     def test_find_etc_raise_correct_error_messages(self):
01226         # issue 11828
01227         s = 'hello'
01228         x = 'x'
01229         self.assertRaisesRegex(TypeError, r'^find\(', s.find,
01230                                 x, None, None, None)
01231         self.assertRaisesRegex(TypeError, r'^rfind\(', s.rfind,
01232                                 x, None, None, None)
01233         self.assertRaisesRegex(TypeError, r'^index\(', s.index,
01234                                 x, None, None, None)
01235         self.assertRaisesRegex(TypeError, r'^rindex\(', s.rindex,
01236                                 x, None, None, None)
01237         self.assertRaisesRegex(TypeError, r'^count\(', s.count,
01238                                 x, None, None, None)
01239         self.assertRaisesRegex(TypeError, r'^startswith\(', s.startswith,
01240                                 x, None, None, None)
01241         self.assertRaisesRegex(TypeError, r'^endswith\(', s.endswith,
01242                                 x, None, None, None)
01243 

Here is the call graph for this function:

Definition at line 1128 of file string_tests.py.

01128 
01129     def test_floatformatting(self):
01130         # float formatting
01131         for prec in range(100):
01132             format = '%%.%if' % prec
01133             value = 0.01
01134             for x in range(60):
01135                 value = value * 3.14159265359 / 3.0 * 10.0
01136                 self.checkcall(format, "__mod__", value)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 1086 of file string_tests.py.

01086 
01087     def test_formatting(self):
01088         self.checkequal('+hello+', '+%s+', '__mod__', 'hello')
01089         self.checkequal('+10+', '+%d+', '__mod__', 10)
01090         self.checkequal('a', "%c", '__mod__', "a")
01091         self.checkequal('a', "%c", '__mod__', "a")
01092         self.checkequal('"', "%c", '__mod__', 34)
01093         self.checkequal('$', "%c", '__mod__', 36)
01094         self.checkequal('10', "%d", '__mod__', 10)
01095         self.checkequal('\x7f', "%c", '__mod__', 0x7f)
01096 
01097         for ordinal in (-100, 0x200000):
01098             # unicode raises ValueError, str raises OverflowError
01099             self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal)
01100 
01101         longvalue = sys.maxsize + 10
01102         slongvalue = str(longvalue)
01103         self.checkequal(' 42', '%3ld', '__mod__', 42)
01104         self.checkequal('42', '%d', '__mod__', 42.0)
01105         self.checkequal(slongvalue, '%d', '__mod__', longvalue)
01106         self.checkcall('%d', '__mod__', float(longvalue))
01107         self.checkequal('0042.00', '%07.2f', '__mod__', 42)
01108         self.checkequal('0042.00', '%07.2F', '__mod__', 42)
01109 
01110         self.checkraises(TypeError, 'abc', '__mod__')
01111         self.checkraises(TypeError, '%(foo)s', '__mod__', 42)
01112         self.checkraises(TypeError, '%s%s', '__mod__', (42,))
01113         self.checkraises(TypeError, '%c', '__mod__', (None,))
01114         self.checkraises(ValueError, '%(foo', '__mod__', {})
01115         self.checkraises(TypeError, '%(foo)s %(bar)s', '__mod__', ('foo', 42))
01116         self.checkraises(TypeError, '%d', '__mod__', "42") # not numeric
01117         self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int conversion provided
01118 
01119         # argument names with properly nested brackets are supported
01120         self.checkequal('bar', '%((foo))s', '__mod__', {'(foo)': 'bar'})
01121 
01122         # 100 is a magic number in PyUnicode_Format, this forces a resize
01123         self.checkequal(103*'a'+'x', '%sx', '__mod__', 103*'a')
01124 
01125         self.checkraises(TypeError, '%*s', '__mod__', ('foo', 'bar'))
01126         self.checkraises(TypeError, '%10.*f', '__mod__', ('foo', 42.))
01127         self.checkraises(ValueError, '%10', '__mod__', (42,))

Here is the call graph for this function:

Definition at line 1137 of file string_tests.py.

01137 
01138     def test_inplace_rewrites(self):
01139         # Check that strings don't copy and modify cached single-character strings
01140         self.checkequal('a', 'A', 'lower')
01141         self.checkequal(True, 'A', 'isupper')
01142         self.checkequal('A', 'a', 'upper')
01143         self.checkequal(True, 'a', 'islower')
01144 
01145         self.checkequal('a', 'A', 'replace', 'A', 'a')
01146         self.checkequal(True, 'A', 'isupper')
01147 
01148         self.checkequal('A', 'a', 'capitalize')
01149         self.checkequal(True, 'a', 'islower')
01150 
01151         self.checkequal('A', 'a', 'swapcase')
01152         self.checkequal(True, 'a', 'islower')
01153 
01154         self.checkequal('A', 'a', 'title')
01155         self.checkequal(True, 'a', 'islower')

Here is the call graph for this function:

Definition at line 858 of file string_tests.py.

00858 
00859     def test_isalnum(self):
00860         self.checkequal(False, '', 'isalnum')
00861         self.checkequal(True, 'a', 'isalnum')
00862         self.checkequal(True, 'A', 'isalnum')
00863         self.checkequal(False, '\n', 'isalnum')
00864         self.checkequal(True, '123abc456', 'isalnum')
00865         self.checkequal(True, 'a1b3c', 'isalnum')
00866         self.checkequal(False, 'aBc000 ', 'isalnum')
00867         self.checkequal(False, 'abc\n', 'isalnum')
00868         self.checkraises(TypeError, 'abc', 'isalnum', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 848 of file string_tests.py.

00848 
00849     def test_isalpha(self):
00850         self.checkequal(False, '', 'isalpha')
00851         self.checkequal(True, 'a', 'isalpha')
00852         self.checkequal(True, 'A', 'isalpha')
00853         self.checkequal(False, '\n', 'isalpha')
00854         self.checkequal(True, 'abc', 'isalpha')
00855         self.checkequal(False, 'aBc123', 'isalpha')
00856         self.checkequal(False, 'abc\n', 'isalpha')
00857         self.checkraises(TypeError, 'abc', 'isalpha', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 869 of file string_tests.py.

00869 
00870     def test_isdigit(self):
00871         self.checkequal(False, '', 'isdigit')
00872         self.checkequal(False, 'a', 'isdigit')
00873         self.checkequal(True, '0', 'isdigit')
00874         self.checkequal(True, '0123456789', 'isdigit')
00875         self.checkequal(False, '0123456789a', 'isdigit')
00876 
00877         self.checkraises(TypeError, 'abc', 'isdigit', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 803 of file string_tests.py.

00803 
00804     def test_islower(self):
00805         self.checkequal(False, '', 'islower')
00806         self.checkequal(True, 'a', 'islower')
00807         self.checkequal(False, 'A', 'islower')
00808         self.checkequal(False, '\n', 'islower')
00809         self.checkequal(True, 'abc', 'islower')
00810         self.checkequal(False, 'aBc', 'islower')
00811         self.checkequal(True, 'abc\n', 'islower')
00812         self.checkraises(TypeError, 'abc', 'islower', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 837 of file string_tests.py.

00837 
00838     def test_isspace(self):
00839         self.checkequal(False, '', 'isspace')
00840         self.checkequal(False, 'a', 'isspace')
00841         self.checkequal(True, ' ', 'isspace')
00842         self.checkequal(True, '\t', 'isspace')
00843         self.checkequal(True, '\r', 'isspace')
00844         self.checkequal(True, '\n', 'isspace')
00845         self.checkequal(True, ' \t\r\n', 'isspace')
00846         self.checkequal(False, ' \t\r\na', 'isspace')
00847         self.checkraises(TypeError, 'abc', 'isspace', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 823 of file string_tests.py.

00823 
00824     def test_istitle(self):
00825         self.checkequal(False, '', 'istitle')
00826         self.checkequal(False, 'a', 'istitle')
00827         self.checkequal(True, 'A', 'istitle')
00828         self.checkequal(False, '\n', 'istitle')
00829         self.checkequal(True, 'A Titlecased Line', 'istitle')
00830         self.checkequal(True, 'A\nTitlecased Line', 'istitle')
00831         self.checkequal(True, 'A Titlecased, Line', 'istitle')
00832         self.checkequal(False, 'Not a capitalized String', 'istitle')
00833         self.checkequal(False, 'Not\ta Titlecase String', 'istitle')
00834         self.checkequal(False, 'Not--a Titlecase String', 'istitle')
00835         self.checkequal(False, 'NOT', 'istitle')
00836         self.checkraises(TypeError, 'abc', 'istitle', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 813 of file string_tests.py.

00813 
00814     def test_isupper(self):
00815         self.checkequal(False, '', 'isupper')
00816         self.checkequal(False, 'a', 'isupper')
00817         self.checkequal(True, 'A', 'isupper')
00818         self.checkequal(False, '\n', 'isupper')
00819         self.checkequal(True, 'ABC', 'isupper')
00820         self.checkequal(False, 'AbC', 'isupper')
00821         self.checkequal(True, 'ABC\n', 'isupper')
00822         self.checkraises(TypeError, 'abc', 'isupper', 42)

Here is the call graph for this function:

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 1050 of file string_tests.py.

01050 
01051     def test_join(self):
01052         # join now works with any sequence type
01053         # moved here, because the argument order is
01054         # different in string.join (see the test in
01055         # test.test_string.StringTest.test_join)
01056         self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
01057         self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd'))
01058         self.checkequal('bd', '', 'join', ('', 'b', '', 'd'))
01059         self.checkequal('ac', '', 'join', ('a', '', 'c', ''))
01060         self.checkequal('w x y z', ' ', 'join', Sequence())
01061         self.checkequal('abc', 'a', 'join', ('abc',))
01062         self.checkequal('z', 'a', 'join', UserList(['z']))
01063         self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c'])
01064         self.assertRaises(TypeError, '.'.join, ['a', 'b', 3])
01065         for i in [5, 25, 125]:
01066             self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
01067                  ['a' * i] * i)
01068             self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
01069                  ('a' * i,) * i)
01070 
01071         #self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1())
01072         self.checkequal('a b c', ' ', 'join', BadSeq2())
01073 
01074         self.checkraises(TypeError, ' ', 'join')
01075         self.checkraises(TypeError, ' ', 'join', 7)
01076         self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()])
01077         try:
01078             def f():
01079                 yield 4 + ""
01080             self.fixtype(' ').join(f())
01081         except TypeError as e:
01082             if '+' not in str(e):
01083                 self.fail('join() ate exception message')
01084         else:
01085             self.fail('exception not raised')

Here is the call graph for this function:

Definition at line 1039 of file string_tests.py.

01039 
01040     def test_mul(self):
01041         self.checkequal('', 'abc', '__mul__', -1)
01042         self.checkequal('', 'abc', '__mul__', 0)
01043         self.checkequal('abc', 'abc', '__mul__', 1)
01044         self.checkequal('abcabcabc', 'abc', '__mul__', 3)
01045         self.checkraises(TypeError, 'abc', '__mul__')
01046         self.checkraises(TypeError, 'abc', '__mul__', '')
01047         # XXX: on a 64-bit system, this doesn't raise an overflow error,
01048         # but either raises a MemoryError, or succeeds (if you have 54TiB)
01049         #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000)

Here is the call graph for this function:

Definition at line 1186 of file string_tests.py.

01186 
01187     def test_none_arguments(self):
01188         # issue 11828
01189         s = 'hello'
01190         self.checkequal(2, s, 'find', 'l', None)
01191         self.checkequal(3, s, 'find', 'l', -2, None)
01192         self.checkequal(2, s, 'find', 'l', None, -2)
01193         self.checkequal(0, s, 'find', 'h', None, None)
01194 
01195         self.checkequal(3, s, 'rfind', 'l', None)
01196         self.checkequal(3, s, 'rfind', 'l', -2, None)
01197         self.checkequal(2, s, 'rfind', 'l', None, -2)
01198         self.checkequal(0, s, 'rfind', 'h', None, None)
01199 
01200         self.checkequal(2, s, 'index', 'l', None)
01201         self.checkequal(3, s, 'index', 'l', -2, None)
01202         self.checkequal(2, s, 'index', 'l', None, -2)
01203         self.checkequal(0, s, 'index', 'h', None, None)
01204 
01205         self.checkequal(3, s, 'rindex', 'l', None)
01206         self.checkequal(3, s, 'rindex', 'l', -2, None)
01207         self.checkequal(2, s, 'rindex', 'l', None, -2)
01208         self.checkequal(0, s, 'rindex', 'h', None, None)
01209 
01210         self.checkequal(2, s, 'count', 'l', None)
01211         self.checkequal(1, s, 'count', 'l', -2, None)
01212         self.checkequal(1, s, 'count', 'l', None, -2)
01213         self.checkequal(0, s, 'count', 'x', None, None)
01214 
01215         self.checkequal(True, s, 'endswith', 'o', None)
01216         self.checkequal(True, s, 'endswith', 'lo', -2, None)
01217         self.checkequal(True, s, 'endswith', 'l', None, -2)
01218         self.checkequal(False, s, 'endswith', 'x', None, None)
01219 
01220         self.checkequal(True, s, 'startswith', 'h', None)
01221         self.checkequal(True, s, 'startswith', 'l', -2, None)
01222         self.checkequal(True, s, 'startswith', 'h', None, -2)
01223         self.checkequal(False, s, 'startswith', 'x', None, None)

Here is the call graph for this function:

Definition at line 1156 of file string_tests.py.

01156 
01157     def test_partition(self):
01158 
01159         self.checkequal(('this is the par', 'ti', 'tion method'),
01160             'this is the partition method', 'partition', 'ti')
01161 
01162         # from raymond's original specification
01163         S = 'http://www.python.org'
01164         self.checkequal(('http', '://', 'www.python.org'), S, 'partition', '://')
01165         self.checkequal(('http://www.python.org', '', ''), S, 'partition', '?')
01166         self.checkequal(('', 'http://', 'www.python.org'), S, 'partition', 'http://')
01167         self.checkequal(('http://www.python.', 'org', ''), S, 'partition', 'org')
01168 
01169         self.checkraises(ValueError, S, 'partition', '')
01170         self.checkraises(TypeError, S, 'partition', None)

Here is the call graph for this function:

Definition at line 1171 of file string_tests.py.

01171 
01172     def test_rpartition(self):
01173 
01174         self.checkequal(('this is the rparti', 'ti', 'on method'),
01175             'this is the rpartition method', 'rpartition', 'ti')
01176 
01177         # from raymond's original specification
01178         S = 'http://www.python.org'
01179         self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://')
01180         self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?')
01181         self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://')
01182         self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org')
01183 
01184         self.checkraises(ValueError, S, 'rpartition', '')
01185         self.checkraises(TypeError, S, 'rpartition', None)

Here is the call graph for this function:

Definition at line 1014 of file string_tests.py.

01014 
01015     def test_slice(self):
01016         self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000))
01017         self.checkequal('abc', 'abc', '__getitem__', slice(0, 3))
01018         self.checkequal('ab', 'abc', '__getitem__', slice(0, 2))
01019         self.checkequal('bc', 'abc', '__getitem__', slice(1, 3))
01020         self.checkequal('b', 'abc', '__getitem__', slice(1, 2))
01021         self.checkequal('', 'abc', '__getitem__', slice(2, 2))
01022         self.checkequal('', 'abc', '__getitem__', slice(1000, 1000))
01023         self.checkequal('', 'abc', '__getitem__', slice(2000, 1000))
01024         self.checkequal('', 'abc', '__getitem__', slice(2, 1))
01025 
01026         self.checkraises(TypeError, 'abc', '__getitem__', 'def')

Here is the call graph for this function:

Definition at line 887 of file string_tests.py.

00887 
00888     def test_splitlines(self):
00889         self.checkequal(['abc', 'def', '', 'ghi'], "abc\ndef\n\rghi", 'splitlines')
00890         self.checkequal(['abc', 'def', '', 'ghi'], "abc\ndef\n\r\nghi", 'splitlines')
00891         self.checkequal(['abc', 'def', 'ghi'], "abc\ndef\r\nghi", 'splitlines')
00892         self.checkequal(['abc', 'def', 'ghi'], "abc\ndef\r\nghi\n", 'splitlines')
00893         self.checkequal(['abc', 'def', 'ghi', ''], "abc\ndef\r\nghi\n\r", 'splitlines')
00894         self.checkequal(['', 'abc', 'def', 'ghi', ''], "\nabc\ndef\r\nghi\n\r", 'splitlines')
00895         self.checkequal(['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], "\nabc\ndef\r\nghi\n\r", 'splitlines', 1)
00896 
00897         self.checkraises(TypeError, 'abc', 'splitlines', 42, 42)

Here is the call graph for this function:

Definition at line 898 of file string_tests.py.

00898 
00899     def test_startswith(self):
00900         self.checkequal(True, 'hello', 'startswith', 'he')
00901         self.checkequal(True, 'hello', 'startswith', 'hello')
00902         self.checkequal(False, 'hello', 'startswith', 'hello world')
00903         self.checkequal(True, 'hello', 'startswith', '')
00904         self.checkequal(False, 'hello', 'startswith', 'ello')
00905         self.checkequal(True, 'hello', 'startswith', 'ello', 1)
00906         self.checkequal(True, 'hello', 'startswith', 'o', 4)
00907         self.checkequal(False, 'hello', 'startswith', 'o', 5)
00908         self.checkequal(True, 'hello', 'startswith', '', 5)
00909         self.checkequal(False, 'hello', 'startswith', 'lo', 6)
00910         self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3)
00911         self.checkequal(True, 'helloworld', 'startswith', 'lowo', 3, 7)
00912         self.checkequal(False, 'helloworld', 'startswith', 'lowo', 3, 6)
00913 
00914         # test negative indices
00915         self.checkequal(True, 'hello', 'startswith', 'he', 0, -1)
00916         self.checkequal(True, 'hello', 'startswith', 'he', -53, -1)
00917         self.checkequal(False, 'hello', 'startswith', 'hello', 0, -1)
00918         self.checkequal(False, 'hello', 'startswith', 'hello world', -1, -10)
00919         self.checkequal(False, 'hello', 'startswith', 'ello', -5)
00920         self.checkequal(True, 'hello', 'startswith', 'ello', -4)
00921         self.checkequal(False, 'hello', 'startswith', 'o', -2)
00922         self.checkequal(True, 'hello', 'startswith', 'o', -1)
00923         self.checkequal(True, 'hello', 'startswith', '', -3, -3)
00924         self.checkequal(False, 'hello', 'startswith', 'lo', -9)
00925 
00926         self.checkraises(TypeError, 'hello', 'startswith')
00927         self.checkraises(TypeError, 'hello', 'startswith', 42)
00928 
00929         # test tuple arguments
00930         self.checkequal(True, 'hello', 'startswith', ('he', 'ha'))
00931         self.checkequal(False, 'hello', 'startswith', ('lo', 'llo'))
00932         self.checkequal(True, 'hello', 'startswith', ('hellox', 'hello'))
00933         self.checkequal(False, 'hello', 'startswith', ())
00934         self.checkequal(True, 'helloworld', 'startswith', ('hellowo',
00935                                                            'rld', 'lowo'), 3)
00936         self.checkequal(False, 'helloworld', 'startswith', ('hellowo', 'ello',
00937                                                             'rld'), 3)
00938         self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1)
00939         self.checkequal(False, 'hello', 'startswith', ('he', 'hel'), 0, 1)
00940         self.checkequal(True, 'hello', 'startswith', ('he', 'hel'), 0, 2)
00941 
00942         self.checkraises(TypeError, 'hello', 'startswith', (42,))

Here is the call graph for this function:

Definition at line 1003 of file string_tests.py.

01003 
01004     def test_subscript(self):
01005         self.checkequal('a', 'abc', '__getitem__', 0)
01006         self.checkequal('c', 'abc', '__getitem__', -1)
01007         self.checkequal('a', 'abc', '__getitem__', 0)
01008         self.checkequal('abc', 'abc', '__getitem__', slice(0, 3))
01009         self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000))
01010         self.checkequal('a', 'abc', '__getitem__', slice(0, 1))
01011         self.checkequal('', 'abc', '__getitem__', slice(0, 0))
01012 
01013         self.checkraises(TypeError, 'abc', '__getitem__', 'def')

Here is the call graph for this function:

Definition at line 878 of file string_tests.py.

00878 
00879     def test_title(self):
00880         self.checkequal(' Hello ', ' hello ', 'title')
00881         self.checkequal('Hello ', 'hello ', 'title')
00882         self.checkequal('Hello ', 'Hello ', 'title')
00883         self.checkequal('Format This As Title String', "fOrMaT thIs aS titLe String", 'title')
00884         self.checkequal('Format,This-As*Title;String', "fOrMaT,thIs-aS*titLe;String", 'title', )
00885         self.checkequal('Getint', "getInt", 'title')
00886         self.checkraises(TypeError, 'hello', 'title', 42)

Here is the call graph for this function:


The documentation for this class was generated from the following file: