MCPcopy Index your code
hub / github.com/python/cpython / test_replace

Method test_replace

Lib/test/test_str.py:581–602  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

579 self.assertRaises(OverflowError, ''.join, seq)
580
581 def test_replace(self):
582 string_tests.StringLikeTest.test_replace(self)
583
584 # method call forwarded from str implementation because of unicode argument
585 self.checkequalnofix('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
586 self.assertRaises(TypeError, 'replace'.replace, "r", 42)
587 # test mixed kinds
588 for left, right in ('ba', '\u0101\u0100', '\U00010301\U00010300'):
589 left *= 9
590 right *= 9
591 for delim in ('c', '\u0102', '\U00010302'):
592 for repl in ('d', '\u0103', '\U00010303'):
593 self.checkequal(left + right,
594 left + right, 'replace', delim, repl)
595 self.checkequal(left + repl + right,
596 left + delim + right,
597 'replace', delim, repl)
598 self.checkequal(left + right,
599 left + right, 'replace', delim * 2, repl)
600 self.checkequal(left + repl + right,
601 left + delim * 2 + right,
602 'replace', delim * 2, repl)
603
604 @support.cpython_only
605 def test_replace_id(self):

Callers

nothing calls this directly

Calls 3

checkequalnofixMethod · 0.95
assertRaisesMethod · 0.45
checkequalMethod · 0.45

Tested by

no test coverage detected