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

Method test_center

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

Source from the content-addressed store, hash-verified

81
82 @bigmemtest(size=_2G + 10, memuse=1)
83 def test_center(self, size):
84 SUBSTR = self.from_latin1(' abc def ghi')
85 s = SUBSTR.center(size)
86 self.assertEqual(len(s), size)
87 lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
88 if len(s) % 2:
89 lpadsize += 1
90 self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
91 self.assertEqual(s.strip(), SUBSTR.strip())
92
93 @bigmemtest(size=_2G, memuse=2)
94 def test_count(self, size):

Callers

nothing calls this directly

Calls 4

from_latin1Method · 0.45
centerMethod · 0.45
assertEqualMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected