MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_replace

Method test_replace

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

Source from the content-addressed store, hash-verified

572 self.assertRaises(OverflowError, ''.join, seq)
573
574 def test_replace(self):
575 string_tests.StringLikeTest.test_replace(self)
576
577 # method call forwarded from str implementation because of unicode argument
578 self.checkequalnofix('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
579 self.assertRaises(TypeError, 'replace'.replace, "r", 42)
580 # test mixed kinds
581 for left, right in ('ba', '\u0101\u0100', '\U00010301\U00010300'):
582 left *= 9
583 right *= 9
584 for delim in ('c', '\u0102', '\U00010302'):
585 for repl in ('d', '\u0103', '\U00010303'):
586 self.checkequal(left + right,
587 left + right, 'replace', delim, repl)
588 self.checkequal(left + repl + right,
589 left + delim + right,
590 'replace', delim, repl)
591 self.checkequal(left + right,
592 left + right, 'replace', delim * 2, repl)
593 self.checkequal(left + repl + right,
594 left + delim * 2 + right,
595 'replace', delim * 2, repl)
596
597 @support.cpython_only
598 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