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

Method test_em_dash

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

Source from the content-addressed store, hash-verified

216 self.check_wrap(text, 1, text.split(), break_long_words=False)
217
218 def test_em_dash(self):
219 # Test text with em-dashes
220 text = "Em-dashes should be written -- thus."
221 self.check_wrap(text, 25,
222 ["Em-dashes should be",
223 "written -- thus."])
224
225 # Probe the boundaries of the properly written em-dash,
226 # ie. " -- ".
227 self.check_wrap(text, 29,
228 ["Em-dashes should be written",
229 "-- thus."])
230 expect = ["Em-dashes should be written --",
231 "thus."]
232 self.check_wrap(text, 30, expect)
233 self.check_wrap(text, 35, expect)
234 self.check_wrap(text, 36,
235 ["Em-dashes should be written -- thus."])
236
237 # The improperly written em-dash is handled too, because
238 # it's adjacent to non-whitespace on both sides.
239 text = "You can also do--this or even---this."
240 expect = ["You can also do",
241 "--this or even",
242 "---this."]
243 self.check_wrap(text, 15, expect)
244 self.check_wrap(text, 16, expect)
245 expect = ["You can also do--",
246 "this or even---",
247 "this."]
248 self.check_wrap(text, 17, expect)
249 self.check_wrap(text, 19, expect)
250 expect = ["You can also do--this or even",
251 "---this."]
252 self.check_wrap(text, 29, expect)
253 self.check_wrap(text, 31, expect)
254 expect = ["You can also do--this or even---",
255 "this."]
256 self.check_wrap(text, 32, expect)
257 self.check_wrap(text, 35, expect)
258
259 # All of the above behaviour could be deduced by probing the
260 # _split() method.
261 text = "Here's an -- em-dash and--here's another---and another!"
262 expect = ["Here's", " ", "an", " ", "--", " ", "em-", "dash", " ",
263 "and", "--", "here's", " ", "another", "---",
264 "and", " ", "another!"]
265 self.check_split(text, expect)
266
267 text = "and then--bam!--he was gone"
268 expect = ["and", " ", "then", "--", "bam!", "--",
269 "he", " ", "was", " ", "gone"]
270 self.check_split(text, expect)
271
272
273 def test_unix_options (self):

Callers

nothing calls this directly

Calls 2

check_wrapMethod · 0.80
check_splitMethod · 0.80

Tested by

no test coverage detected