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

Method test_translate

Lib/test/test_bigmem.py:745–762  ·  view source on GitHub ↗
(self, size)

Source from the content-addressed store, hash-verified

743
744 @bigmemtest(size=_2G, memuse=ascii_char_size * 2 + ucs4_char_size)
745 def test_translate(self, size):
746 _ = self.from_latin1
747 SUBSTR = _('aZz.z.Aaz.')
748 trans = {
749 ord(_('.')): _('-'),
750 ord(_('a')): _('!'),
751 ord(_('Z')): _('$'),
752 }
753 sublen = len(SUBSTR)
754 repeats = size // sublen + 2
755 s = SUBSTR * repeats
756 s = s.translate(trans)
757 self.assertEqual(len(s), repeats * sublen)
758 self.assertEqual(s[:sublen], SUBSTR.translate(trans))
759 self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
760 self.assertEqual(s.count(_('.')), 0)
761 self.assertEqual(s.count(_('!')), repeats * 2)
762 self.assertEqual(s.count(_('z')), repeats * 3)
763
764
765class BytesTest(unittest.TestCase, BaseStrTest):

Callers

nothing calls this directly

Calls 6

ordFunction · 0.85
lenFunction · 0.85
_Function · 0.70
translateMethod · 0.45
assertEqualMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected