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

Method test_translate

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

Source from the content-addressed store, hash-verified

441
442 @bigmemtest(size=_2G, memuse=2)
443 def test_translate(self, size):
444 _ = self.from_latin1
445 SUBSTR = _('aZz.z.Aaz.')
446 trans = bytes.maketrans(b'.aZ', b'-!$')
447 sublen = len(SUBSTR)
448 repeats = size // sublen + 2
449 s = SUBSTR * repeats
450 s = s.translate(trans)
451 self.assertEqual(len(s), repeats * sublen)
452 self.assertEqual(s[:sublen], SUBSTR.translate(trans))
453 self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
454 self.assertEqual(s.count(_('.')), 0)
455 self.assertEqual(s.count(_('!')), repeats * 2)
456 self.assertEqual(s.count(_('z')), repeats * 3)
457
458 @bigmemtest(size=_2G + 5, memuse=2)
459 def test_upper(self, size):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected