• Home
  • Raw
  • Download

Lines Matching +full:check +full:- +full:whitespace

30     def check(self, result, expect):  member in BaseTestCase
37 self.check(result, expect)
69 # Check that wrapping the empty string returns an empty list.
74 # Check that the empty string is not indented.
79 # Whitespace munging and end-of-sentence detection
97 self.check(result, expect)
100 self.check(result, '\n'.join(expect))
118 self.check(wrapper.wrap(text), expect)
125 self.check(wrapper.wrap(text), expect)
128 self.check(wrapper.wrap(text), expect)
132 self.check(wrapper.wrap(text), expect)
136 self.check(wrapper.wrap(text), expect)
142 self.check(wrapper.wrap(text), expect)
146 self.check(wrapper.wrap(text), expect)
150 self.check(wrapper.wrap(text), expect)
175 text = ("this-is-a-useful-feature-for-"
176 "reformatting-posts-from-tim-peters'ly")
179 ["this-is-a-useful-feature-for-",
180 "reformatting-posts-from-tim-peters'ly"])
182 ["this-is-a-useful-feature-for-",
183 "reformatting-posts-from-tim-peters'ly"])
185 ["this-is-a-useful-feature-for-reformatting-",
186 "posts-from-tim-peters'ly"])
188 expect = ("this-|is-|a-|useful-|feature-|for-|"
189 "reformatting-|posts-|from-|tim-|peters'ly").split('|')
193 self.check_split('e-mail', ['e-mail'])
194 self.check_split('Jelly-O', ['Jelly-O'])
196 self.check_split('half-a-crown', 'half-|a-|crown'.split('|'))
200 text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n"
201 "released on 1994-02-15.")
204 '1994-01-26. Python 1.0.1 was',
205 'released on 1994-02-15.'])
206 self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
207 'Python 1.0.1 was released on 1994-02-15.'])
210 text = "I do all my shopping at 7-11."
212 "7-11."])
214 "7-11."])
215 self.check_wrap(text, 29, ["I do all my shopping at 7-11."])
219 # Test text with em-dashes
220 text = "Em-dashes should be written -- thus."
222 ["Em-dashes should be",
223 "written -- thus."])
225 # Probe the boundaries of the properly written em-dash,
226 # ie. " -- ".
228 ["Em-dashes should be written",
229 "-- thus."])
230 expect = ["Em-dashes should be written --",
235 ["Em-dashes should be written -- thus."])
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."
241 "--this or even",
242 "---this."]
245 expect = ["You can also do--",
246 "this or even---",
250 expect = ["You can also do--this or even",
251 "---this."]
254 expect = ["You can also do--this or even---",
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", "---",
267 text = "and then--bam!--he was gone"
268 expect = ["and", " ", "then", "--", "bam!", "--",
274 # Test that Unix-style command-line options are wrapped correctly.
277 text = "You should use the -n option, or --dry-run in its long form."
280 "-n option, or --dry-",
284 ["You should use the -n",
285 "option, or --dry-run",
287 expect = ["You should use the -n option, or",
288 "--dry-run in its long form."]
293 expect = ["You should use the -n option, or --dry-",
297 expect = ["You should use the -n option, or --dry-run",
302 text = "the -n option, or --dry-run or --dryrun"
303 expect = ["the", " ", "-n", " ", "option,", " ", "or", " ",
304 "--dry-", "run", " ", "or", " ", "--dryrun"]
310 self.check_split("what the--hey!", ["what", " ", "the", "--", "hey!"])
311 self.check_split("what the--", ["what", " ", "the--"])
312 self.check_split("what the--.", ["what", " ", "the--."])
313 self.check_split("--text--.", ["--text--."])
319 self.check_split("--option", ["--option"])
320 self.check_split("--option-opt", ["--option-", "opt"])
321 self.check_split("foo --option-opt bar",
322 ["foo", " ", "--option-", "opt", " ", "bar"])
325 # Oh bother, SF #965425 found another problem with hyphens --
328 # word was handled incorrectly, except for a leading "--", which
329 # was special-cased for Optik and Docutils. So test a variety
332 self.check_split("the 'wibble-wobble' widget",
333 ['the', ' ', "'wibble-", "wobble'", ' ', 'widget'])
334 self.check_split('the "wibble-wobble" widget',
335 ['the', ' ', '"wibble-', 'wobble"', ' ', 'widget'])
336 self.check_split("the (wibble-wobble) widget",
337 ['the', ' ', "(wibble-", "wobble)", ' ', 'widget'])
338 self.check_split("the ['wibble-wobble'] widget",
339 ['the', ' ', "['wibble-", "wobble']", ' ', 'widget'])
342 self.check_split("what-d'you-call-it.",
343 "what-d'you-|call-|it.".split('|'))
348 self.check_split("foo (--option) bar",
349 ["foo", " ", "(--option)", " ", "bar"])
351 # Related stuff -- make sure parens work in simpler contexts.
359 # Check that drop_whitespace=False preserves whitespace.
361 text = " This is a sentence with much whitespace."
368 # Check that drop_whitespace=False preserves a whitespace-only string.
372 # Check that a whitespace-only string gets indented (when
378 # Check drop_whitespace on a whitespace-only string.
382 # Check that drop_whitespace does not drop leading whitespace (if
383 # followed by non-whitespace).
385 # whitespace; let's test that a bit, shall we?
386 text = " This is a sentence with leading whitespace."
388 [" This is a sentence with leading whitespace."])
390 [" This is a sentence with", "leading whitespace."])
393 # Check that drop_whitespace skips the whole line if a non-leading
394 # line consists only of whitespace.
402 # Check that initial_indent is not applied to a whitespace-only
404 # whitespace occurs before indenting.
408 # Check that drop_whitespace does not drop whitespace indents.
409 # This checks a special case of the fact that dropping whitespace
418 text = "Hello there -- you goof-ball, use the -b option!"
421 self.check(result,
422 ["Hello", " ", "there", " ", "--", " ", "you", " ", "goof-",
423 "ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"])
427 text = "yaba daba-doo"
428 self.check_wrap(text, 10, ["yaba daba-", "doo"],
430 self.check_wrap(text, 10, ["yaba", "daba-doo"],
437 self.assertRaises(ValueError, wrap, text, -1)
440 text = "Die Empf\xe4nger-Auswahl"
441 self.check_wrap(text, 13, ["Die", "Empf\xe4nger-", "Auswahl"])
444 text = "aa \xe4\xe4-\xe4\xe4"
445 self.check_wrap(text, 7, ["aa \xe4\xe4-", "\xe4\xe4"])
448 text = 'This is a sentence with non-breaking\N{NO-BREAK SPACE}space.'
452 'with non-',
453 'breaking\N{NO-BREAK SPACE}space.'],
459 'non-breaking\N{NO-BREAK SPACE}space.'],
463 text = ('This is a sentence with non-breaking'
464 '\N{NARROW NO-BREAK SPACE}space.')
468 'with non-',
469 'breaking\N{NARROW NO-BREAK SPACE}space.'],
475 'non-breaking\N{NARROW NO-BREAK SPACE}space.'],
596 self.check_wrap('-'*10+'hello', 10,
597 ['----------',
628 self.check(result, expect)
632 self.check(result, expect)
647 We used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate synthase.
650 1234567890-1234567890--this_is_a_very_long_option_indeed-good-bye"
654 expected = ['We used enyzme 2-succinyl-6-hydroxy-2,4-',
655 'cyclohexadiene-1-carboxylate synthase.']
658 expected = ['We used', 'enyzme 2-', 'succinyl-', '6-hydroxy-', '2,4-',
659 'cyclohexad', 'iene-1-', 'carboxylat', 'e', 'synthase.']
662 expected = ['1234567890', '-123456789', '0--this_is', '_a_very_lo',
663 'ng_option_', 'indeed-', 'good-bye"']
667 expected = ['We used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexad',
668 'iene-1-carboxylate synthase.']
671 expected = ['We used', 'enyzme 2-s', 'uccinyl-6-', 'hydroxy-2,',
672 '4-cyclohex', 'adiene-1-c', 'arboxylate', 'synthase.']
675 expected = ['1234567890', '-123456789', '0--this_is', '_a_very_lo',
676 'ng_option_', 'indeed-', 'good-bye"']
681 '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate',
687 '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate',
691 expected = ['1234567890', '-123456789', '0--this_is', '_a_very_lo',
692 'ng_option_', 'indeed-', 'good-bye"']
698 '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate',
705 '2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate',
711 expected = ['1234567890', '-123456789', '0--this_is', '_a_very_lo',
712 'ng_option_', 'indeed-', 'good-bye"']
733 self.check(result, expect)
743 self.check(result, expect)
747 self.check(result, expect)
761 self.check(result, expect)
824 # Uneven indentation with a whitespace-only line.
840 # Declining indent level with whitespace only line.
866 # dedent() only removes whitespace that can be uniformly removed!
933 # A whitespace prefix should roundtrip with dedent
938 # A whitespace prefix should roundtrip with dedent
943 # A whitespace prefix should roundtrip with dedent
948 # Test default indenting of lines that are not whitespace only
966 # Test default indenting of lines that are not whitespace only
984 # Add 'prefix' to all lines, including whitespace-only ones.
1003 # Add 'prefix' solely to whitespace-only lines.
1026 self.check(result, expect)
1034 self.check_shorten(text, len(text) - 1,
1045 self.check_shorten(text, len(text) - 1,
1053 # Whitespace collapsing