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

Method test_translate

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

maketransMethod · 0.80
_Function · 0.70
translateMethod · 0.45
assertEqualMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected