Lines Matching refs:text

35     def check_wrap(self, text, width, expect, **kwargs):
36 result = wrap(text, width, **kwargs)
39 def check_split(self, text, expect):
40 result = self.wrapper._split(text)
54 text = "Hello there, how are you this fine day? I'm glad to hear it!"
56 self.check_wrap(text, 12,
63 self.check_wrap(text, 42,
66 self.check_wrap(text, 80, [text])
81 text = """\
96 result = wrapper.wrap(text)
99 result = wrapper.fill(text)
102 text = "\tTest\tdefault\t\ttabsize."
104 self.check_wrap(text, 80, expect)
106 text = "\tTest\tcustom\t\ttabsize."
108 self.check_wrap(text, 80, expect, tabsize=4)
116 text = "A short line. Note the single space."
118 self.check(wrapper.wrap(text), expect)
123 text = "Well, Doctor? What do you think?"
125 self.check(wrapper.wrap(text), expect)
127 text = "Well, Doctor?\nWhat do you think?"
128 self.check(wrapper.wrap(text), expect)
130 text = 'I say, chaps! Anyone for "tennis?"\nHmmph!'
132 self.check(wrapper.wrap(text), expect)
136 self.check(wrapper.wrap(text), expect)
138 text = 'And she said, "Go to hell!"\nCan you believe that?'
142 self.check(wrapper.wrap(text), expect)
146 self.check(wrapper.wrap(text), expect)
148 text = 'File stdio.h is nice.'
150 self.check(wrapper.wrap(text), expect)
155 text = "This is a\nshort paragraph."
157 self.check_wrap(text, 20, ["This is a short",
159 self.check_wrap(text, 40, ["This is a short paragraph."])
165 text = "This is a short line."
167 self.check_wrap(text, 30, ["This is a short line."])
168 self.check_wrap(text, 30, ["(1) This is a short line."],
175 text = ("this-is-a-useful-feature-for-"
178 self.check_wrap(text, 40,
181 self.check_wrap(text, 41,
184 self.check_wrap(text, 42,
190 self.check_wrap(text, 1, expect, break_long_words=False)
191 self.check_split(text, expect)
200 text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n"
203 self.check_wrap(text, 30, ['Python 1.0.0 was released on',
206 self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
208 self.check_wrap(text, 1, text.split(), break_long_words=False)
210 text = "I do all my shopping at 7-11."
211 self.check_wrap(text, 25, ["I do all my shopping at",
213 self.check_wrap(text, 27, ["I do all my shopping at",
215 self.check_wrap(text, 29, ["I do all my shopping at 7-11."])
216 self.check_wrap(text, 1, text.split(), break_long_words=False)
219 # Test text with em-dashes
220 text = "Em-dashes should be written -- thus."
221 self.check_wrap(text, 25,
227 self.check_wrap(text, 29,
232 self.check_wrap(text, 30, expect)
233 self.check_wrap(text, 35, expect)
234 self.check_wrap(text, 36,
239 text = "You can also do--this or even---this."
243 self.check_wrap(text, 15, expect)
244 self.check_wrap(text, 16, expect)
248 self.check_wrap(text, 17, expect)
249 self.check_wrap(text, 19, expect)
252 self.check_wrap(text, 29, expect)
253 self.check_wrap(text, 31, expect)
256 self.check_wrap(text, 32, expect)
257 self.check_wrap(text, 35, expect)
261 text = "Here's an -- em-dash and--here's another---and another!"
265 self.check_split(text, expect)
267 text = "and then--bam!--he was gone"
270 self.check_split(text, expect)
277 text = "You should use the -n option, or --dry-run in its long form."
278 self.check_wrap(text, 20,
283 self.check_wrap(text, 21,
289 self.check_wrap(text, 32, expect)
290 self.check_wrap(text, 34, expect)
291 self.check_wrap(text, 35, expect)
292 self.check_wrap(text, 38, expect)
295 self.check_wrap(text, 39, expect)
296 self.check_wrap(text, 41, expect)
299 self.check_wrap(text, 42, expect)
302 text = "the -n option, or --dry-run or --dryrun"
305 self.check_split(text, expect)
313 self.check_split("--text--.", ["--text--."])
361 text = " This is a sentence with much whitespace."
362 self.check_wrap(text, 10,
386 text = " This is a sentence with leading whitespace."
387 self.check_wrap(text, 50,
389 self.check_wrap(text, 30,
395 text = "abcd efgh"
397 self.check_wrap(text, 6, ["abcd", " ", "efgh"],
399 self.check_wrap(text, 6, ["abcd", "efgh"])
418 text = "Hello there -- you goof-ball, use the -b option!"
420 result = self.wrapper._split(text)
427 text = "yaba daba-doo"
428 self.check_wrap(text, 10, ["yaba daba-", "doo"],
430 self.check_wrap(text, 10, ["yaba", "daba-doo"],
435 text = "Whatever, it doesn't matter."
436 self.assertRaises(ValueError, wrap, text, 0)
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.'
450 self.check_wrap(text, 20,
456 self.check_wrap(text, 20,
463 text = ('This is a sentence with non-breaking'
466 self.check_wrap(text, 20,
472 self.check_wrap(text, 20,
480 text = "Hello there, how are you this fine day? I'm glad to hear it!"
483 self.check_wrap(self.text, 12,
486 self.check_wrap(self.text, 12,
489 self.check_wrap(self.text, 12,
493 self.check_wrap(self.text, 13,
497 self.check_wrap(self.text, 80, [self.text], max_lines=1)
498 self.check_wrap(self.text, 12,
509 self.check_wrap(self.text, 12,
516 self.check_wrap(self.text, 6,
521 self.check_wrap(self.text + ' ' * 10, 12,
531 self.check_wrap(self.text, 12,
535 self.check_wrap(self.text, 12,
542 wrap(self.text, 16, initial_indent=' ',
545 wrap(self.text, 16, subsequent_indent=' ',
547 self.check_wrap(self.text, 16,
554 self.check_wrap(self.text, 16,
560 self.check_wrap(self.text, 80, [self.text], placeholder='.' * 1000)
566 self.text = '''\
572 # Wrap text with long words and lots of punctuation
574 self.check_wrap(self.text, 30,
579 self.check_wrap(self.text, 50,
596 self.check_wrap(self.text, 12,
616 result = self.wrapper.wrap(self.text)
620 result = wrap(self.text, width=30, break_long_words=0)
624 self.check_wrap(self.text, 12,
636 self.text = '''\
649 result = fill(self.text, 40)
659 result = wrap(self.text, 40, initial_indent=" ")
663 result = fill(self.text, 40, initial_indent=" ")
676 result = fill(self.text, 40,
685 def assertUnchanged(self, text):
686 """assert that dedent() has no effect on 'text'"""
687 self.assertEqual(text, dedent(text))
691 text = "Hello there.\nHow are you?\nOh good, I'm glad."
692 self.assertUnchanged(text)
695 text = "Hello there.\n\nBoo!"
696 self.assertUnchanged(text)
699 text = "Hello there.\n This is indented."
700 self.assertUnchanged(text)
703 text = "Hello there.\n\n Boo!\n"
704 self.assertUnchanged(text)
708 text = " Hello there.\n How are ya?\n Oh good."
710 self.assertEqual(expect, dedent(text))
713 text = " Hello there.\n\n How are ya?\n Oh good.\n"
715 self.assertEqual(expect, dedent(text))
718 text = " Hello there.\n \n How are ya?\n Oh good.\n"
720 self.assertEqual(expect, dedent(text))
724 text = '''\
734 self.assertEqual(expect, dedent(text))
737 text = " Foo\n Bar\n\n Baz\n"
739 self.assertEqual(expect, dedent(text))
742 text = " Foo\n Bar\n \n Baz\n"
744 self.assertEqual(expect, dedent(text))
748 text = " hello\tthere\n how are\tyou?"
750 self.assertEqual(expect, dedent(text))
760 text = " hello there\n\thow are you?"
761 self.assertUnchanged(text)
764 text = " hello there\n\thow are you?"
765 self.assertUnchanged(text)
768 text = "\thello there\n\thow are you?"
770 self.assertEqual(expect, dedent(text))
772 text = " \thello there\n \thow are you?"
773 self.assertEqual(expect, dedent(text))
775 text = " \t hello there\n \t how are you?"
776 self.assertEqual(expect, dedent(text))
778 text = " \thello there\n \t how are you?"
780 self.assertEqual(expect, dedent(text))
783 text = " \thello there\n \thow are you?\n \tI'm fine, thanks"
785 self.assertEqual(expect, dedent(text))
811 for text in self.CASES:
812 self.assertEqual(indent(text, ''), text)
817 for text in self.CASES:
818 self.assertEqual(indent(text, '', None), text)
824 for text in self.CASES:
825 self.assertEqual(indent(text, '', predicate), text)
830 for text in self.CASES:
831 self.assertEqual(indent(text, ' ', predicate), text)
835 for text in self.ROUNDTRIP_CASES:
836 self.assertEqual(dedent(indent(text, ' ')), text)
840 for text in self.ROUNDTRIP_CASES:
841 self.assertEqual(dedent(indent(text, '\t\t')), text)
845 for text in self.ROUNDTRIP_CASES:
846 self.assertEqual(dedent(indent(text, ' \t \t ')), text)
863 for text, expect in zip(self.CASES, expected):
864 self.assertEqual(indent(text, prefix), expect)
881 for text, expect in zip(self.CASES, expected):
882 self.assertEqual(indent(text, prefix, None), expect)
900 for text, expect in zip(self.CASES, expected):
901 self.assertEqual(indent(text, prefix, predicate), expect)
919 for text, expect in zip(self.CASES, expected):
920 self.assertEqual(indent(text, prefix, predicate), expect)
925 def check_shorten(self, text, width, expect, **kwargs):
926 result = shorten(text, width, **kwargs)
931 text = "Hello there, how are you this fine day? I'm glad to hear it!"
933 self.check_shorten(text, 18, "Hello there, [...]")
934 self.check_shorten(text, len(text), text)
935 self.check_shorten(text, len(text) - 1,
940 text = "Hello there, how are you this fine day? I'm glad to hear it!"
942 self.check_shorten(text, 17, "Hello there,$$", placeholder='$$')
943 self.check_shorten(text, 18, "Hello there, how$$", placeholder='$$')
944 self.check_shorten(text, 18, "Hello there, $$", placeholder=' $$')
945 self.check_shorten(text, len(text), text, placeholder='$$')
946 self.check_shorten(text, len(text) - 1,
955 text = """
958 self.check_shorten(text, 62,
961 self.check_shorten(text, 61,