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

Method test_fix_sentence_endings

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

Source from the content-addressed store, hash-verified

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)
112
113 # SF #847346: ensure that fix_sentence_endings=True does the
114 # right thing even on input short enough that it doesn't need to
115 # be wrapped.
116 text = "A short line. Note the single space."
117 expect = ["A short line. Note the single space."]
118 self.check(wrapper.wrap(text), expect)
119
120 # Test some of the hairy end cases that _fix_sentence_endings()
121 # is supposed to handle (the easy stuff is tested in
122 # test_whitespace() above).
123 text = "Well, Doctor? What do you think?"
124 expect = ["Well, Doctor? What do you think?"]
125 self.check(wrapper.wrap(text), expect)
126
127 text = "Well, Doctor?\nWhat do you think?"
128 self.check(wrapper.wrap(text), expect)
129
130 text = 'I say, chaps! Anyone for "tennis?"\nHmmph!'
131 expect = ['I say, chaps! Anyone for "tennis?" Hmmph!']
132 self.check(wrapper.wrap(text), expect)
133
134 wrapper.width = 20
135 expect = ['I say, chaps!', 'Anyone for "tennis?"', 'Hmmph!']
136 self.check(wrapper.wrap(text), expect)
137
138 text = 'And she said, "Go to hell!"\nCan you believe that?'
139 expect = ['And she said, "Go to',
140 'hell!" Can you',
141 'believe that?']
142 self.check(wrapper.wrap(text), expect)
143
144 wrapper.width = 60
145 expect = ['And she said, "Go to hell!" Can you believe that?']
146 self.check(wrapper.wrap(text), expect)
147
148 text = 'File stdio.h is nice.'
149 expect = ['File stdio.h is nice.']
150 self.check(wrapper.wrap(text), expect)
151
152 def test_wrap_short(self):
153 # Wrapping to make short lines longer

Callers

nothing calls this directly

Calls 3

wrapMethod · 0.95
TextWrapperClass · 0.90
checkMethod · 0.45

Tested by

no test coverage detected