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

Method test_whitespace

Lib/test/test_textwrap.py:78–108  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

76 self.check_wrap("", 6, [], initial_indent="++", drop_whitespace=False)
77
78 def test_whitespace(self):
79 # Whitespace munging and end-of-sentence detection
80
81 text = """\
82This is a paragraph that already has
83line breaks. But some of its lines are much longer than the others,
84so it needs to be wrapped.
85Some lines are \ttabbed too.
86What a mess!
87"""
88
89 expect = ["This is a paragraph that already has line",
90 "breaks. But some of its lines are much",
91 "longer than the others, so it needs to be",
92 "wrapped. Some lines are tabbed too. What a",
93 "mess!"]
94
95 wrapper = TextWrapper(45, fix_sentence_endings=True)
96 result = wrapper.wrap(text)
97 self.check(result, expect)
98
99 result = wrapper.fill(text)
100 self.check(result, '\n'.join(expect))
101
102 text = "\tTest\tdefault\t\ttabsize."
103 expect = [" Test default tabsize."]
104 self.check_wrap(text, 80, expect)
105
106 text = "\tTest\tcustom\t\ttabsize."
107 expect = [" Test custom tabsize."]
108 self.check_wrap(text, 80, expect, tabsize=4)
109
110 def test_fix_sentence_endings(self):
111 wrapper = TextWrapper(60, fix_sentence_endings=True)

Callers

nothing calls this directly

Calls 6

wrapMethod · 0.95
fillMethod · 0.95
TextWrapperClass · 0.90
check_wrapMethod · 0.80
checkMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected