@@ -55,8 +55,7 @@ def duplicate_string(text):
55
55
class StrSubclass (str ):
56
56
pass
57
57
58
- class UnicodeTest (string_tests .CommonTest ,
59
- string_tests .MixinStrUnicodeUserStringTest ,
58
+ class StrTest (string_tests .StringLikeTest ,
60
59
string_tests .MixinStrUnicodeTest ,
61
60
unittest .TestCase ):
62
61
@@ -213,7 +212,7 @@ def test_pickle_iterator(self):
213
212
self .assertEqual (case , pickled )
214
213
215
214
def test_count (self ):
216
- string_tests .CommonTest .test_count (self )
215
+ string_tests .StringLikeTest .test_count (self )
217
216
# check mixed argument types
218
217
self .checkequalnofix (3 , 'aaa' , 'count' , 'a' )
219
218
self .checkequalnofix (0 , 'aaa' , 'count' , 'b' )
@@ -243,7 +242,7 @@ class MyStr(str):
243
242
self .checkequal (3 , MyStr ('aaa' ), 'count' , 'a' )
244
243
245
244
def test_find (self ):
246
- string_tests .CommonTest .test_find (self )
245
+ string_tests .StringLikeTest .test_find (self )
247
246
# test implementation details of the memchr fast path
248
247
self .checkequal (100 , 'a' * 100 + '\u0102 ' , 'find' , '\u0102 ' )
249
248
self .checkequal (- 1 , 'a' * 100 + '\u0102 ' , 'find' , '\u0201 ' )
@@ -288,7 +287,7 @@ def test_find(self):
288
287
self .checkequal (- 1 , '\u0102 ' * 100 , 'find' , '\u0102 \U00100304 ' )
289
288
290
289
def test_rfind (self ):
291
- string_tests .CommonTest .test_rfind (self )
290
+ string_tests .StringLikeTest .test_rfind (self )
292
291
# test implementation details of the memrchr fast path
293
292
self .checkequal (0 , '\u0102 ' + 'a' * 100 , 'rfind' , '\u0102 ' )
294
293
self .checkequal (- 1 , '\u0102 ' + 'a' * 100 , 'rfind' , '\u0201 ' )
@@ -329,7 +328,7 @@ def test_rfind(self):
329
328
self .checkequal (- 1 , '\u0102 ' * 100 , 'rfind' , '\U00100304 \u0102 ' )
330
329
331
330
def test_index (self ):
332
- string_tests .CommonTest .test_index (self )
331
+ string_tests .StringLikeTest .test_index (self )
333
332
self .checkequalnofix (0 , 'abcdefghiabc' , 'index' , '' )
334
333
self .checkequalnofix (3 , 'abcdefghiabc' , 'index' , 'def' )
335
334
self .checkequalnofix (0 , 'abcdefghiabc' , 'index' , 'abc' )
@@ -353,7 +352,7 @@ def test_index(self):
353
352
self .assertRaises (ValueError , ('\u0102 ' * 100 ).index , '\u0102 \U00100304 ' )
354
353
355
354
def test_rindex (self ):
356
- string_tests .CommonTest .test_rindex (self )
355
+ string_tests .StringLikeTest .test_rindex (self )
357
356
self .checkequalnofix (12 , 'abcdefghiabc' , 'rindex' , '' )
358
357
self .checkequalnofix (3 , 'abcdefghiabc' , 'rindex' , 'def' )
359
358
self .checkequalnofix (9 , 'abcdefghiabc' , 'rindex' , 'abc' )
@@ -449,7 +448,7 @@ def test_maketrans_translate(self):
449
448
self .assertRaises (TypeError , 'abababc' .translate , 'abc' , 'xyz' )
450
449
451
450
def test_split (self ):
452
- string_tests .CommonTest .test_split (self )
451
+ string_tests .StringLikeTest .test_split (self )
453
452
454
453
# test mixed kinds
455
454
for left , right in ('ba' , '\u0101 \u0100 ' , '\U00010301 \U00010300 ' ):
@@ -466,7 +465,7 @@ def test_split(self):
466
465
left + delim * 2 + right , 'split' , delim * 2 )
467
466
468
467
def test_rsplit (self ):
469
- string_tests .CommonTest .test_rsplit (self )
468
+ string_tests .StringLikeTest .test_rsplit (self )
470
469
# test mixed kinds
471
470
for left , right in ('ba' , 'юё' , '\u0101 \u0100 ' , '\U00010301 \U00010300 ' ):
472
471
left *= 9
@@ -486,7 +485,7 @@ def test_rsplit(self):
486
485
left + right , 'rsplit' , None )
487
486
488
487
def test_partition (self ):
489
- string_tests .MixinStrUnicodeUserStringTest .test_partition (self )
488
+ string_tests .StringLikeTest .test_partition (self )
490
489
# test mixed kinds
491
490
self .checkequal (('ABCDEFGH' , '' , '' ), 'ABCDEFGH' , 'partition' , '\u4200 ' )
492
491
for left , right in ('ba' , '\u0101 \u0100 ' , '\U00010301 \U00010300 ' ):
@@ -503,7 +502,7 @@ def test_partition(self):
503
502
left + delim * 2 + right , 'partition' , delim * 2 )
504
503
505
504
def test_rpartition (self ):
506
- string_tests .MixinStrUnicodeUserStringTest .test_rpartition (self )
505
+ string_tests .StringLikeTest .test_rpartition (self )
507
506
# test mixed kinds
508
507
self .checkequal (('' , '' , 'ABCDEFGH' ), 'ABCDEFGH' , 'rpartition' , '\u4200 ' )
509
508
for left , right in ('ba' , '\u0101 \u0100 ' , '\U00010301 \U00010300 ' ):
@@ -520,7 +519,7 @@ def test_rpartition(self):
520
519
left + delim * 2 + right , 'rpartition' , delim * 2 )
521
520
522
521
def test_join (self ):
523
- string_tests .MixinStrUnicodeUserStringTest .test_join (self )
522
+ string_tests .StringLikeTest .test_join (self )
524
523
525
524
class MyWrapper :
526
525
def __init__ (self , sval ): self .sval = sval
@@ -547,7 +546,7 @@ def test_join_overflow(self):
547
546
self .assertRaises (OverflowError , '' .join , seq )
548
547
549
548
def test_replace (self ):
550
- string_tests .CommonTest .test_replace (self )
549
+ string_tests .StringLikeTest .test_replace (self )
551
550
552
551
# method call forwarded from str implementation because of unicode argument
553
552
self .checkequalnofix ('one@two!three!' , 'one!two!three!' , 'replace' , '!' , '@' , 1 )
@@ -866,7 +865,7 @@ def test_surrogates(self):
866
865
867
866
868
867
def test_lower (self ):
869
- string_tests .CommonTest .test_lower (self )
868
+ string_tests .StringLikeTest .test_lower (self )
870
869
self .assertEqual ('\U00010427 ' .lower (), '\U0001044F ' )
871
870
self .assertEqual ('\U00010427 \U00010427 ' .lower (),
872
871
'\U0001044F \U0001044F ' )
@@ -897,7 +896,7 @@ def test_casefold(self):
897
896
self .assertEqual ('\u00b5 ' .casefold (), '\u03bc ' )
898
897
899
898
def test_upper (self ):
900
- string_tests .CommonTest .test_upper (self )
899
+ string_tests .StringLikeTest .test_upper (self )
901
900
self .assertEqual ('\U0001044F ' .upper (), '\U00010427 ' )
902
901
self .assertEqual ('\U0001044F \U0001044F ' .upper (),
903
902
'\U00010427 \U00010427 ' )
@@ -914,7 +913,7 @@ def test_upper(self):
914
913
self .assertEqual ('\u2177 ' .upper (), '\u2167 ' )
915
914
916
915
def test_capitalize (self ):
917
- string_tests .CommonTest .test_capitalize (self )
916
+ string_tests .StringLikeTest .test_capitalize (self )
918
917
self .assertEqual ('\U0001044F ' .capitalize (), '\U00010427 ' )
919
918
self .assertEqual ('\U0001044F \U0001044F ' .capitalize (),
920
919
'\U00010427 \U0001044F ' )
@@ -948,7 +947,7 @@ def test_title(self):
948
947
self .assertEqual ('A\u03a3 A' .title (), 'A\u03c3 a' )
949
948
950
949
def test_swapcase (self ):
951
- string_tests .CommonTest .test_swapcase (self )
950
+ string_tests .StringLikeTest .test_swapcase (self )
952
951
self .assertEqual ('\U0001044F ' .swapcase (), '\U00010427 ' )
953
952
self .assertEqual ('\U00010427 ' .swapcase (), '\U0001044F ' )
954
953
self .assertEqual ('\U0001044F \U0001044F ' .swapcase (),
@@ -974,7 +973,7 @@ def test_swapcase(self):
974
973
self .assertEqual ('\u1fd2 ' .swapcase (), '\u0399 \u0308 \u0300 ' )
975
974
976
975
def test_center (self ):
977
- string_tests .CommonTest .test_center (self )
976
+ string_tests .StringLikeTest .test_center (self )
978
977
self .assertEqual ('x' .center (2 , '\U0010FFFF ' ),
979
978
'x\U0010FFFF ' )
980
979
self .assertEqual ('x' .center (3 , '\U0010FFFF ' ),
@@ -1475,7 +1474,7 @@ def __format__(self, spec):
1475
1474
self .assertEqual ('{f:{}}{}{g}' .format (2 , 4 , f = 1 , g = 'g' ), ' 14g' )
1476
1475
1477
1476
def test_formatting (self ):
1478
- string_tests .MixinStrUnicodeUserStringTest .test_formatting (self )
1477
+ string_tests .StringLikeTest .test_formatting (self )
1479
1478
# Testing Unicode formatting strings...
1480
1479
self .assertEqual ("%s, %s" % ("abc" , "abc" ), 'abc, abc' )
1481
1480
self .assertEqual ("%s, %s, %i, %f, %5.2f" % ("abc" , "abc" , 1 , 2 , 3 ), 'abc, abc, 1, 2.000000, 3.00' )
0 commit comments