Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.test_userstring.UserStringTest Class Reference
Inheritance diagram for test.test_userstring.UserStringTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_userstring.UserStringTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def checkequal
def checkraises
def checkcall
def test_hash
def test_capitalize
def test_lower
def test_upper
def test_expandtabs
def test_additional_split
def test_additional_rsplit
def test_strip
def test_ljust
def test_rjust
def test_center
def test_swapcase
def test_zfill
def fixtype
def test_count
def test_find
def test_rfind
def test_index
def test_rindex
def test_split
def test_rsplit
def test_replace
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

Static Public Attributes

 type2test = UserString

Detailed Description

Definition at line 13 of file test_userstring.py.


Member Function Documentation

def test.test_userstring.UserStringTest.checkcall (   self,
  object,
  methodname,
  args 
)

Reimplemented from test.string_tests.BaseTest.

Definition at line 39 of file test_userstring.py.

00039 
00040     def checkcall(self, object, methodname, *args):
00041         object = self.fixtype(object)
00042         # we don't fix the arguments, because UserString can't cope with it
00043         getattr(object, methodname)(*args)
00044 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_userstring.UserStringTest.checkequal (   self,
  result,
  object,
  methodname,
  args 
)

Reimplemented from test.string_tests.BaseTest.

Definition at line 20 of file test_userstring.py.

00020 
00021     def checkequal(self, result, object, methodname, *args):
00022         result = self.fixtype(result)
00023         object = self.fixtype(object)
00024         # we don't fix the arguments, because UserString can't cope with it
00025         realresult = getattr(object, methodname)(*args)
00026         self.assertEqual(
00027             result,
00028             realresult
00029         )

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_userstring.UserStringTest.checkraises (   self,
  exc,
  object,
  methodname,
  args 
)

Reimplemented from test.string_tests.BaseTest.

Definition at line 30 of file test_userstring.py.

00030 
00031     def checkraises(self, exc, object, methodname, *args):
00032         object = self.fixtype(object)
00033         # we don't fix the arguments, because UserString can't cope with it
00034         self.assertRaises(
00035             exc,
00036             getattr(object, methodname),
00037             *args
00038         )

Here is the call graph for this function:

Here is the caller graph for this function:

def test.string_tests.BaseTest.fixtype (   self,
  obj 
) [inherited]

Reimplemented in test.test_bytes.FixedStringTest.

Definition at line 34 of file string_tests.py.

00034 
00035     def fixtype(self, obj):
00036         if isinstance(obj, str):
00037             return self.__class__.type2test(obj)
00038         elif isinstance(obj, list):
00039             return [self.fixtype(x) for x in obj]
00040         elif isinstance(obj, tuple):
00041             return tuple([self.fixtype(x) for x in obj])
00042         elif isinstance(obj, dict):
00043             return dict([
00044                (self.fixtype(key), self.fixtype(value))
00045                for (key, value) in obj.items()
00046             ])
00047         else:
00048             return obj

Here is the call graph for this function:

Here is the caller graph for this function:

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 698 of file string_tests.py.

00698 
00699     def test_additional_rsplit(self):
00700         self.checkequal(['this', 'is', 'the', 'rsplit', 'function'],
00701                          'this is the rsplit function', 'rsplit')
00702 
00703         # by whitespace
00704         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'rsplit')
00705         self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1)
00706         self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
00707         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3)
00708         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4)
00709         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None,
00710                         sys.maxsize-20)
00711         self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0)
00712         self.checkequal(['a b c d'], 'a b c d  ', 'rsplit', None, 0)
00713         self.checkequal(['a  b', 'c', 'd'], 'a  b  c  d', 'rsplit', None, 2)
00714 
00715         self.checkequal([], '         ', 'rsplit')
00716         self.checkequal(['a'], '  a    ', 'rsplit')
00717         self.checkequal(['a', 'b'], '  a    b   ', 'rsplit')
00718         self.checkequal(['  a', 'b'], '  a    b   ', 'rsplit', None, 1)
00719         self.checkequal(['  a    b','c'], '  a    b   c   ', 'rsplit',
00720                         None, 1)
00721         self.checkequal(['  a', 'b', 'c'], '  a    b   c   ', 'rsplit',
00722                         None, 2)
00723         self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88)
00724         aaa = ' a '*20
00725         self.checkequal(['a']*20, aaa, 'rsplit')
00726         self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1)
00727         self.checkequal([' a  a'] + ['a']*18, aaa, 'rsplit', None, 18)
00728 
00729         # mixed use of str and unicode
00730         self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', ' ', 2)

Here is the call graph for this function:

Definition at line 667 of file string_tests.py.

00667 
00668     def test_additional_split(self):
00669         self.checkequal(['this', 'is', 'the', 'split', 'function'],
00670             'this is the split function', 'split')
00671 
00672         # by whitespace
00673         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split')
00674         self.checkequal(['a', 'b c d'], 'a b c d', 'split', None, 1)
00675         self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2)
00676         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3)
00677         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4)
00678         self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None,
00679                         sys.maxsize-1)
00680         self.checkequal(['a b c d'], 'a b c d', 'split', None, 0)
00681         self.checkequal(['a b c d'], '  a b c d', 'split', None, 0)
00682         self.checkequal(['a', 'b', 'c  d'], 'a  b  c  d', 'split', None, 2)
00683 
00684         self.checkequal([], '         ', 'split')
00685         self.checkequal(['a'], '  a    ', 'split')
00686         self.checkequal(['a', 'b'], '  a    b   ', 'split')
00687         self.checkequal(['a', 'b   '], '  a    b   ', 'split', None, 1)
00688         self.checkequal(['a', 'b   c   '], '  a    b   c   ', 'split', None, 1)
00689         self.checkequal(['a', 'b', 'c   '], '  a    b   c   ', 'split', None, 2)
00690         self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split')
00691         aaa = ' a '*20
00692         self.checkequal(['a']*20, aaa, 'split')
00693         self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1)
00694         self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19)
00695 
00696         # mixed use of str and unicode
00697         self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', ' ', 2)

Here is the call graph for this function:

Definition at line 637 of file string_tests.py.

00637 
00638     def test_capitalize(self):
00639         self.checkequal(' hello ', ' hello ', 'capitalize')
00640         self.checkequal('Hello ', 'Hello ','capitalize')
00641         self.checkequal('Hello ', 'hello ','capitalize')
00642         self.checkequal('Aaaa', 'aaaa', 'capitalize')
00643         self.checkequal('Aaaa', 'AaAa', 'capitalize')
00644 
00645         self.checkraises(TypeError, 'hello', 'capitalize', 42)

Here is the call graph for this function:

def test.string_tests.CommonTest.test_center (   self) [inherited]

Definition at line 769 of file string_tests.py.

00769 
00770     def test_center(self):
00771         self.checkequal('   abc    ', 'abc', 'center', 10)
00772         self.checkequal(' abc  ', 'abc', 'center', 6)
00773         self.checkequal('abc', 'abc', 'center', 3)
00774         self.checkequal('abc', 'abc', 'center', 2)
00775         self.checkequal('***abc****', 'abc', 'center', 10, '*')
00776         self.checkraises(TypeError, 'abc', 'center')

Here is the call graph for this function:

def test.string_tests.BaseTest.test_count (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 88 of file string_tests.py.

00088 
00089     def test_count(self):
00090         self.checkequal(3, 'aaa', 'count', 'a')
00091         self.checkequal(0, 'aaa', 'count', 'b')
00092         self.checkequal(3, 'aaa', 'count', 'a')
00093         self.checkequal(0, 'aaa', 'count', 'b')
00094         self.checkequal(3, 'aaa', 'count', 'a')
00095         self.checkequal(0, 'aaa', 'count', 'b')
00096         self.checkequal(0, 'aaa', 'count', 'b')
00097         self.checkequal(2, 'aaa', 'count', 'a', 1)
00098         self.checkequal(0, 'aaa', 'count', 'a', 10)
00099         self.checkequal(1, 'aaa', 'count', 'a', -1)
00100         self.checkequal(3, 'aaa', 'count', 'a', -10)
00101         self.checkequal(1, 'aaa', 'count', 'a', 0, 1)
00102         self.checkequal(3, 'aaa', 'count', 'a', 0, 10)
00103         self.checkequal(2, 'aaa', 'count', 'a', 0, -1)
00104         self.checkequal(0, 'aaa', 'count', 'a', 0, -10)
00105         self.checkequal(3, 'aaa', 'count', '', 1)
00106         self.checkequal(1, 'aaa', 'count', '', 3)
00107         self.checkequal(0, 'aaa', 'count', '', 10)
00108         self.checkequal(2, 'aaa', 'count', '', -1)
00109         self.checkequal(4, 'aaa', 'count', '', -10)
00110 
00111         self.checkequal(1, '', 'count', '')
00112         self.checkequal(0, '', 'count', '', 1, 1)
00113         self.checkequal(0, '', 'count', '', sys.maxsize, 0)
00114 
00115         self.checkequal(0, '', 'count', 'xx')
00116         self.checkequal(0, '', 'count', 'xx', 1, 1)
00117         self.checkequal(0, '', 'count', 'xx', sys.maxsize, 0)
00118 
00119         self.checkraises(TypeError, 'hello', 'count')
00120         self.checkraises(TypeError, 'hello', 'count', 42)
00121 
00122         # For a variety of combinations,
00123         #    verify that str.count() matches an equivalent function
00124         #    replacing all occurrences and then differencing the string lengths
00125         charset = ['', 'a', 'b']
00126         digits = 7
00127         base = len(charset)
00128         teststrings = set()
00129         for i in range(base ** digits):
00130             entry = []
00131             for j in range(digits):
00132                 i, m = divmod(i, base)
00133                 entry.append(charset[m])
00134             teststrings.add(''.join(entry))
00135         teststrings = [self.fixtype(ts) for ts in teststrings]
00136         for i in teststrings:
00137             n = len(i)
00138             for j in teststrings:
00139                 r1 = i.count(j)
00140                 if j:
00141                     r2, rem = divmod(n - len(i.replace(j, self.fixtype(''))),
00142                                      len(j))
00143                 else:
00144                     r2, rem = len(i)+1, 0
00145                 if rem or r1 != r2:
00146                     self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i))
00147                     self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i))

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:

Reimplemented from test.string_tests.BaseTest.

Definition at line 656 of file string_tests.py.

00656 
00657     def test_expandtabs(self):
00658         self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
00659         self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
00660         self.checkequal('abc\rab  def\ng   hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4)
00661         self.checkequal('abc\r\nab  def\ng   hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4)
00662         self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
00663         self.checkequal('abc\rab      def\ng       hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
00664         self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4)
00665 
00666         self.checkraises(TypeError, 'hello', 'expandtabs', 42, 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:

def test.string_tests.BaseTest.test_find (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 148 of file string_tests.py.

00148 
00149     def test_find(self):
00150         self.checkequal(0, 'abcdefghiabc', 'find', 'abc')
00151         self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1)
00152         self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4)
00153 
00154         self.checkequal(0, 'abc', 'find', '', 0)
00155         self.checkequal(3, 'abc', 'find', '', 3)
00156         self.checkequal(-1, 'abc', 'find', '', 4)
00157 
00158         # to check the ability to pass None as defaults
00159         self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a')
00160         self.checkequal(12, 'rrarrrrrrrrra', 'find', 'a', 4)
00161         self.checkequal(-1, 'rrarrrrrrrrra', 'find', 'a', 4, 6)
00162         self.checkequal(12, 'rrarrrrrrrrra', 'find', 'a', 4, None)
00163         self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a', None, 6)
00164 
00165         self.checkraises(TypeError, 'hello', 'find')
00166         self.checkraises(TypeError, 'hello', 'find', 42)
00167 
00168         self.checkequal(0, '', 'find', '')
00169         self.checkequal(-1, '', 'find', '', 1, 1)
00170         self.checkequal(-1, '', 'find', '', sys.maxsize, 0)
00171 
00172         self.checkequal(-1, '', 'find', 'xx')
00173         self.checkequal(-1, '', 'find', 'xx', 1, 1)
00174         self.checkequal(-1, '', 'find', 'xx', sys.maxsize, 0)
00175 
00176         # issue 7458
00177         self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
00178 
00179         # For a variety of combinations,
00180         #    verify that str.find() matches __contains__
00181         #    and that the found substring is really at that location
00182         charset = ['', 'a', 'b', 'c']
00183         digits = 5
00184         base = len(charset)
00185         teststrings = set()
00186         for i in range(base ** digits):
00187             entry = []
00188             for j in range(digits):
00189                 i, m = divmod(i, base)
00190                 entry.append(charset[m])
00191             teststrings.add(''.join(entry))
00192         teststrings = [self.fixtype(ts) for ts in teststrings]
00193         for i in teststrings:
00194             for j in teststrings:
00195                 loc = i.find(j)
00196                 r1 = (loc != -1)
00197                 r2 = j in i
00198                 self.assertEqual(r1, r2)
00199                 if loc != -1:
00200                     self.assertEqual(i[loc:loc+len(j)], j)

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:

def test.string_tests.CommonTest.test_hash (   self) [inherited]

Definition at line 628 of file string_tests.py.

00628 
00629     def test_hash(self):
00630         # SF bug 1054139:  += optimization was not invalidating cached hash value
00631         a = self.type2test('DNSSEC')
00632         b = self.type2test('')
00633         for c in a:
00634             b += c
00635             hash(b)
00636         self.assertEqual(hash(a), hash(b))

Here is the call graph for this function:

def test.string_tests.BaseTest.test_index (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 247 of file string_tests.py.

00247 
00248     def test_index(self):
00249         self.checkequal(0, 'abcdefghiabc', 'index', '')
00250         self.checkequal(3, 'abcdefghiabc', 'index', 'def')
00251         self.checkequal(0, 'abcdefghiabc', 'index', 'abc')
00252         self.checkequal(9, 'abcdefghiabc', 'index', 'abc', 1)
00253 
00254         self.checkraises(ValueError, 'abcdefghiabc', 'index', 'hib')
00255         self.checkraises(ValueError, 'abcdefghiab', 'index', 'abc', 1)
00256         self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', 8)
00257         self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', -1)
00258 
00259         # to check the ability to pass None as defaults
00260         self.checkequal( 2, 'rrarrrrrrrrra', 'index', 'a')
00261         self.checkequal(12, 'rrarrrrrrrrra', 'index', 'a', 4)
00262         self.checkraises(ValueError, 'rrarrrrrrrrra', 'index', 'a', 4, 6)
00263         self.checkequal(12, 'rrarrrrrrrrra', 'index', 'a', 4, None)
00264         self.checkequal( 2, 'rrarrrrrrrrra', 'index', 'a', None, 6)
00265 
00266         self.checkraises(TypeError, 'hello', 'index')
00267         self.checkraises(TypeError, 'hello', 'index', 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:

def test.string_tests.CommonTest.test_ljust (   self) [inherited]

Definition at line 753 of file string_tests.py.

00753 
00754     def test_ljust(self):
00755         self.checkequal('abc       ', 'abc', 'ljust', 10)
00756         self.checkequal('abc   ', 'abc', 'ljust', 6)
00757         self.checkequal('abc', 'abc', 'ljust', 3)
00758         self.checkequal('abc', 'abc', 'ljust', 2)
00759         self.checkequal('abc*******', 'abc', 'ljust', 10, '*')
00760         self.checkraises(TypeError, 'abc', 'ljust')

Here is the call graph for this function:

def test.string_tests.CommonTest.test_lower (   self) [inherited]

Reimplemented from test.string_tests.BaseTest.

Definition at line 646 of file string_tests.py.

00646 
00647     def test_lower(self):
00648         self.checkequal('hello', 'HeLLo', 'lower')
00649         self.checkequal('hello', 'hello', 'lower')
00650         self.checkraises(TypeError, 'hello', 'lower', 42)

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:

def test.string_tests.BaseTest.test_replace (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 430 of file string_tests.py.

00430 
00431     def test_replace(self):
00432         EQ = self.checkequal
00433 
00434         # Operations on the empty string
00435         EQ("", "", "replace", "", "")
00436         EQ("A", "", "replace", "", "A")
00437         EQ("", "", "replace", "A", "")
00438         EQ("", "", "replace", "A", "A")
00439         EQ("", "", "replace", "", "", 100)
00440         EQ("", "", "replace", "", "", sys.maxsize)
00441 
00442         # interleave (from=="", 'to' gets inserted everywhere)
00443         EQ("A", "A", "replace", "", "")
00444         EQ("*A*", "A", "replace", "", "*")
00445         EQ("*1A*1", "A", "replace", "", "*1")
00446         EQ("*-#A*-#", "A", "replace", "", "*-#")
00447         EQ("*-A*-A*-", "AA", "replace", "", "*-")
00448         EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
00449         EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize)
00450         EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
00451         EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
00452         EQ("*-A*-A", "AA", "replace", "", "*-", 2)
00453         EQ("*-AA", "AA", "replace", "", "*-", 1)
00454         EQ("AA", "AA", "replace", "", "*-", 0)
00455 
00456         # single character deletion (from=="A", to=="")
00457         EQ("", "A", "replace", "A", "")
00458         EQ("", "AAA", "replace", "A", "")
00459         EQ("", "AAA", "replace", "A", "", -1)
00460         EQ("", "AAA", "replace", "A", "", sys.maxsize)
00461         EQ("", "AAA", "replace", "A", "", 4)
00462         EQ("", "AAA", "replace", "A", "", 3)
00463         EQ("A", "AAA", "replace", "A", "", 2)
00464         EQ("AA", "AAA", "replace", "A", "", 1)
00465         EQ("AAA", "AAA", "replace", "A", "", 0)
00466         EQ("", "AAAAAAAAAA", "replace", "A", "")
00467         EQ("BCD", "ABACADA", "replace", "A", "")
00468         EQ("BCD", "ABACADA", "replace", "A", "", -1)
00469         EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize)
00470         EQ("BCD", "ABACADA", "replace", "A", "", 5)
00471         EQ("BCD", "ABACADA", "replace", "A", "", 4)
00472         EQ("BCDA", "ABACADA", "replace", "A", "", 3)
00473         EQ("BCADA", "ABACADA", "replace", "A", "", 2)
00474         EQ("BACADA", "ABACADA", "replace", "A", "", 1)
00475         EQ("ABACADA", "ABACADA", "replace", "A", "", 0)
00476         EQ("BCD", "ABCAD", "replace", "A", "")
00477         EQ("BCD", "ABCADAA", "replace", "A", "")
00478         EQ("BCD", "BCD", "replace", "A", "")
00479         EQ("*************", "*************", "replace", "A", "")
00480         EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999)
00481 
00482         # substring deletion (from=="the", to=="")
00483         EQ("", "the", "replace", "the", "")
00484         EQ("ater", "theater", "replace", "the", "")
00485         EQ("", "thethe", "replace", "the", "")
00486         EQ("", "thethethethe", "replace", "the", "")
00487         EQ("aaaa", "theatheatheathea", "replace", "the", "")
00488         EQ("that", "that", "replace", "the", "")
00489         EQ("thaet", "thaet", "replace", "the", "")
00490         EQ("here and re", "here and there", "replace", "the", "")
00491         EQ("here and re and re", "here and there and there",
00492            "replace", "the", "", sys.maxsize)
00493         EQ("here and re and re", "here and there and there",
00494            "replace", "the", "", -1)
00495         EQ("here and re and re", "here and there and there",
00496            "replace", "the", "", 3)
00497         EQ("here and re and re", "here and there and there",
00498            "replace", "the", "", 2)
00499         EQ("here and re and there", "here and there and there",
00500            "replace", "the", "", 1)
00501         EQ("here and there and there", "here and there and there",
00502            "replace", "the", "", 0)
00503         EQ("here and re and re", "here and there and there", "replace", "the", "")
00504 
00505         EQ("abc", "abc", "replace", "the", "")
00506         EQ("abcdefg", "abcdefg", "replace", "the", "")
00507 
00508         # substring deletion (from=="bob", to=="")
00509         EQ("bob", "bbobob", "replace", "bob", "")
00510         EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "")
00511         EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "")
00512         EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "")
00513 
00514         # single character replace in place (len(from)==len(to)==1)
00515         EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
00516         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
00517         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize)
00518         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
00519         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
00520         EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
00521         EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1)
00522         EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0)
00523 
00524         EQ("Who goes there?", "Who goes there?", "replace", "a", "q")
00525         EQ("who goes there?", "Who goes there?", "replace", "W", "w")
00526         EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w")
00527         EQ("Who goes there!", "Who goes there?", "replace", "?", "!")
00528         EQ("Who goes there!!", "Who goes there??", "replace", "?", "!")
00529 
00530         EQ("Who goes there?", "Who goes there?", "replace", ".", "!")
00531 
00532         # substring replace in place (len(from)==len(to) > 1)
00533         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
00534         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize)
00535         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
00536         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
00537         EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
00538         EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2)
00539         EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1)
00540         EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0)
00541         EQ("cobob", "bobob", "replace", "bob", "cob")
00542         EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob")
00543         EQ("bobob", "bobob", "replace", "bot", "bot")
00544 
00545         # replace single character (len(from)==1, len(to)>1)
00546         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
00547         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
00548         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize)
00549         EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
00550         EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
00551         EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
00552         EQ("A----B----C----", "A.B.C.", "replace", ".", "----")
00553 
00554         EQ("Reykjavik", "Reykjavik", "replace", "q", "KK")
00555 
00556         # replace substring (len(from)>1, len(to)!=len(from))
00557         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
00558            "replace", "spam", "ham")
00559         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
00560            "replace", "spam", "ham", sys.maxsize)
00561         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
00562            "replace", "spam", "ham", -1)
00563         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
00564            "replace", "spam", "ham", 4)
00565         EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
00566            "replace", "spam", "ham", 3)
00567         EQ("ham, ham, eggs and spam", "spam, spam, eggs and spam",
00568            "replace", "spam", "ham", 2)
00569         EQ("ham, spam, eggs and spam", "spam, spam, eggs and spam",
00570            "replace", "spam", "ham", 1)
00571         EQ("spam, spam, eggs and spam", "spam, spam, eggs and spam",
00572            "replace", "spam", "ham", 0)
00573 
00574         EQ("bobob", "bobobob", "replace", "bobob", "bob")
00575         EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
00576         EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
00577 
00578         # XXX Commented out. Is there any reason to support buffer objects
        # as arguments for str.replace()?  GvR

Here is the call graph for this function:

def test.string_tests.BaseTest.test_rfind (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 201 of file string_tests.py.

00201 
00202     def test_rfind(self):
00203         self.checkequal(9,  'abcdefghiabc', 'rfind', 'abc')
00204         self.checkequal(12, 'abcdefghiabc', 'rfind', '')
00205         self.checkequal(0, 'abcdefghiabc', 'rfind', 'abcd')
00206         self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz')
00207 
00208         self.checkequal(3, 'abc', 'rfind', '', 0)
00209         self.checkequal(3, 'abc', 'rfind', '', 3)
00210         self.checkequal(-1, 'abc', 'rfind', '', 4)
00211 
00212         # to check the ability to pass None as defaults
00213         self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a')
00214         self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a', 4)
00215         self.checkequal(-1, 'rrarrrrrrrrra', 'rfind', 'a', 4, 6)
00216         self.checkequal(12, 'rrarrrrrrrrra', 'rfind', 'a', 4, None)
00217         self.checkequal( 2, 'rrarrrrrrrrra', 'rfind', 'a', None, 6)
00218 
00219         self.checkraises(TypeError, 'hello', 'rfind')
00220         self.checkraises(TypeError, 'hello', 'rfind', 42)
00221 
00222         # For a variety of combinations,
00223         #    verify that str.rfind() matches __contains__
00224         #    and that the found substring is really at that location
00225         charset = ['', 'a', 'b', 'c']
00226         digits = 5
00227         base = len(charset)
00228         teststrings = set()
00229         for i in range(base ** digits):
00230             entry = []
00231             for j in range(digits):
00232                 i, m = divmod(i, base)
00233                 entry.append(charset[m])
00234             teststrings.add(''.join(entry))
00235         teststrings = [self.fixtype(ts) for ts in teststrings]
00236         for i in teststrings:
00237             for j in teststrings:
00238                 loc = i.rfind(j)
00239                 r1 = (loc != -1)
00240                 r2 = j in i
00241                 self.assertEqual(r1, r2)
00242                 if loc != -1:
00243                     self.assertEqual(i[loc:loc+len(j)], j)
00244 
00245         # issue 7458
00246         self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)

Here is the call graph for this function:

def test.string_tests.BaseTest.test_rindex (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 268 of file string_tests.py.

00268 
00269     def test_rindex(self):
00270         self.checkequal(12, 'abcdefghiabc', 'rindex', '')
00271         self.checkequal(3,  'abcdefghiabc', 'rindex', 'def')
00272         self.checkequal(9,  'abcdefghiabc', 'rindex', 'abc')
00273         self.checkequal(0,  'abcdefghiabc', 'rindex', 'abc', 0, -1)
00274 
00275         self.checkraises(ValueError, 'abcdefghiabc', 'rindex', 'hib')
00276         self.checkraises(ValueError, 'defghiabc', 'rindex', 'def', 1)
00277         self.checkraises(ValueError, 'defghiabc', 'rindex', 'abc', 0, -1)
00278         self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, 8)
00279         self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, -1)
00280 
00281         # to check the ability to pass None as defaults
00282         self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a')
00283         self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4)
00284         self.checkraises(ValueError, 'rrarrrrrrrrra', 'rindex', 'a', 4, 6)
00285         self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4, None)
00286         self.checkequal( 2, 'rrarrrrrrrrra', 'rindex', 'a', None, 6)
00287 
00288         self.checkraises(TypeError, 'hello', 'rindex')
00289         self.checkraises(TypeError, 'hello', 'rindex', 42)

Here is the call graph for this function:

def test.string_tests.CommonTest.test_rjust (   self) [inherited]

Definition at line 761 of file string_tests.py.

00761 
00762     def test_rjust(self):
00763         self.checkequal('       abc', 'abc', 'rjust', 10)
00764         self.checkequal('   abc', 'abc', 'rjust', 6)
00765         self.checkequal('abc', 'abc', 'rjust', 3)
00766         self.checkequal('abc', 'abc', 'rjust', 2)
00767         self.checkequal('*******abc', 'abc', 'rjust', 10, '*')
00768         self.checkraises(TypeError, 'abc', 'rjust')

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:

def test.string_tests.BaseTest.test_rsplit (   self) [inherited]

Definition at line 373 of file string_tests.py.

00373 
00374     def test_rsplit(self):
00375         # by a char
00376         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|')
00377         self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1)
00378         self.checkequal(['a|b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 2)
00379         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3)
00380         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4)
00381         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|',
00382                         sys.maxsize-100)
00383         self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0)
00384         self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2)
00385         self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|')
00386         self.checkequal(['endcase ', ''], 'endcase |', 'rsplit', '|')
00387         self.checkequal(['', 'bothcase', ''], '|bothcase|', 'rsplit', '|')
00388 
00389         self.checkequal(['a\x00\x00b', 'c', 'd'], 'a\x00\x00b\x00c\x00d', 'rsplit', '\x00', 2)
00390 
00391         self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|')
00392         self.checkequal(['a|a|a|a|a']+['a']*15,
00393                         ('a|'*20)[:-1], 'rsplit', '|', 15)
00394 
00395         # by string
00396         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//')
00397         self.checkequal(['a//b//c', 'd'], 'a//b//c//d', 'rsplit', '//', 1)
00398         self.checkequal(['a//b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 2)
00399         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3)
00400         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4)
00401         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//',
00402                         sys.maxsize-5)
00403         self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0)
00404         self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2)
00405         self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test')
00406         self.checkequal(['endcase ', ''], 'endcase test', 'rsplit', 'test')
00407         self.checkequal(['', ' bothcase ', ''], 'test bothcase test',
00408                         'rsplit', 'test')
00409         self.checkequal(['ab', 'c'], 'abbbc', 'rsplit', 'bb')
00410         self.checkequal(['', ''], 'aaa', 'rsplit', 'aaa')
00411         self.checkequal(['aaa'], 'aaa', 'rsplit', 'aaa', 0)
00412         self.checkequal(['ab', 'ab'], 'abbaab', 'rsplit', 'ba')
00413         self.checkequal(['aaaa'], 'aaaa', 'rsplit', 'aab')
00414         self.checkequal([''], '', 'rsplit', 'aaa')
00415         self.checkequal(['aa'], 'aa', 'rsplit', 'aaa')
00416         self.checkequal(['bbob', 'A'], 'bbobbbobbA', 'rsplit', 'bbobb')
00417         self.checkequal(['', 'B', 'A'], 'bbobbBbbobbA', 'rsplit', 'bbobb')
00418 
00419         self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH')
00420         self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19)
00421         self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4],
00422                         'rsplit', 'BLAH', 18)
00423 
00424         # argument type
00425         self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42)
00426 
00427         # null case
00428         self.checkraises(ValueError, 'hello', 'rsplit', '')
00429         self.checkraises(ValueError, 'hello', 'rsplit', '', 0)

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:

def test.string_tests.BaseTest.test_split (   self) [inherited]

Reimplemented in test.test_unicode.UnicodeTest.

Definition at line 316 of file string_tests.py.

00316 
00317     def test_split(self):
00318         # by a char
00319         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|')
00320         self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0)
00321         self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1)
00322         self.checkequal(['a', 'b', 'c|d'], 'a|b|c|d', 'split', '|', 2)
00323         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3)
00324         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4)
00325         self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|',
00326                         sys.maxsize-2)
00327         self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0)
00328         self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2)
00329         self.checkequal(['endcase ', ''], 'endcase |', 'split', '|')
00330         self.checkequal(['', ' startcase'], '| startcase', 'split', '|')
00331         self.checkequal(['', 'bothcase', ''], '|bothcase|', 'split', '|')
00332         self.checkequal(['a', '', 'b\x00c\x00d'], 'a\x00\x00b\x00c\x00d', 'split', '\x00', 2)
00333 
00334         self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|')
00335         self.checkequal(['a']*15 +['a|a|a|a|a'],
00336                                    ('a|'*20)[:-1], 'split', '|', 15)
00337 
00338         # by string
00339         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//')
00340         self.checkequal(['a', 'b//c//d'], 'a//b//c//d', 'split', '//', 1)
00341         self.checkequal(['a', 'b', 'c//d'], 'a//b//c//d', 'split', '//', 2)
00342         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3)
00343         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4)
00344         self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//',
00345                         sys.maxsize-10)
00346         self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0)
00347         self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2)
00348         self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test')
00349         self.checkequal(['', ' begincase'], 'test begincase', 'split', 'test')
00350         self.checkequal(['', ' bothcase ', ''], 'test bothcase test',
00351                         'split', 'test')
00352         self.checkequal(['a', 'bc'], 'abbbc', 'split', 'bb')
00353         self.checkequal(['', ''], 'aaa', 'split', 'aaa')
00354         self.checkequal(['aaa'], 'aaa', 'split', 'aaa', 0)
00355         self.checkequal(['ab', 'ab'], 'abbaab', 'split', 'ba')
00356         self.checkequal(['aaaa'], 'aaaa', 'split', 'aab')
00357         self.checkequal([''], '', 'split', 'aaa')
00358         self.checkequal(['aa'], 'aa', 'split', 'aaa')
00359         self.checkequal(['A', 'bobb'], 'Abbobbbobb', 'split', 'bbobb')
00360         self.checkequal(['A', 'B', ''], 'AbbobbBbbobb', 'split', 'bbobb')
00361 
00362         self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH')
00363         self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19)
00364         self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4],
00365                         'split', 'BLAH', 18)
00366 
00367         # argument type
00368         self.checkraises(TypeError, 'hello', 'split', 42, 42, 42)
00369 
00370         # null case
00371         self.checkraises(ValueError, 'hello', 'split', '')
00372         self.checkraises(ValueError, 'hello', 'split', '', 0)

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:

def test.string_tests.CommonTest.test_strip (   self) [inherited]

Definition at line 731 of file string_tests.py.

00731 
00732     def test_strip(self):
00733         self.checkequal('hello', '   hello   ', 'strip')
00734         self.checkequal('hello   ', '   hello   ', 'lstrip')
00735         self.checkequal('   hello', '   hello   ', 'rstrip')
00736         self.checkequal('hello', 'hello', 'strip')
00737 
00738         # strip/lstrip/rstrip with None arg
00739         self.checkequal('hello', '   hello   ', 'strip', None)
00740         self.checkequal('hello   ', '   hello   ', 'lstrip', None)
00741         self.checkequal('   hello', '   hello   ', 'rstrip', None)
00742         self.checkequal('hello', 'hello', 'strip', None)
00743 
00744         # strip/lstrip/rstrip with str arg
00745         self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz')
00746         self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz')
00747         self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz')
00748         self.checkequal('hello', 'hello', 'strip', 'xyz')
00749 
00750         self.checkraises(TypeError, 'hello', 'strip', 42, 42)
00751         self.checkraises(TypeError, 'hello', 'lstrip', 42, 42)
00752         self.checkraises(TypeError, 'hello', 'rstrip', 42, 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:

def test.string_tests.CommonTest.test_swapcase (   self) [inherited]

Definition at line 777 of file string_tests.py.

00777 
00778     def test_swapcase(self):
00779         self.checkequal('hEllO CoMPuTErS', 'HeLLo cOmpUteRs', 'swapcase')
00780 
00781         self.checkraises(TypeError, 'hello', 'swapcase', 42)

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:

def test.string_tests.CommonTest.test_upper (   self) [inherited]

Reimplemented from test.string_tests.BaseTest.

Definition at line 651 of file string_tests.py.

00651 
00652     def test_upper(self):
00653         self.checkequal('HELLO', 'HeLLo', 'upper')
00654         self.checkequal('HELLO', 'HELLO', 'upper')
00655         self.checkraises(TypeError, 'hello', 'upper', 42)

Here is the call graph for this function:

def test.string_tests.CommonTest.test_zfill (   self) [inherited]

Definition at line 782 of file string_tests.py.

00782 
00783     def test_zfill(self):
00784         self.checkequal('123', '123', 'zfill', 2)
00785         self.checkequal('123', '123', 'zfill', 3)
00786         self.checkequal('0123', '123', 'zfill', 4)
00787         self.checkequal('+123', '+123', 'zfill', 3)
00788         self.checkequal('+123', '+123', 'zfill', 4)
00789         self.checkequal('+0123', '+123', 'zfill', 5)
00790         self.checkequal('-123', '-123', 'zfill', 3)
00791         self.checkequal('-123', '-123', 'zfill', 4)
00792         self.checkequal('-0123', '-123', 'zfill', 5)
00793         self.checkequal('000', '', 'zfill', 3)
00794         self.checkequal('34', '34', 'zfill', 1)
00795         self.checkequal('0034', '34', 'zfill', 4)
00796 
00797         self.checkraises(TypeError, '123', 'zfill')

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.string_tests.BaseTest.

Definition at line 15 of file test_userstring.py.


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