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)
567 text = 'Good grief Python features are advancing quickly!'
568 self.check_wrap(text, 12,
577 self.text = '''\
583 # Wrap text with long words and lots of punctuation
585 self.check_wrap(self.text, 30,
590 self.check_wrap(self.text, 50,
607 self.check_wrap(self.text, 12,
627 result = self.wrapper.wrap(self.text)
631 result = wrap(self.text, width=30, break_long_words=0)
635 self.check_wrap(self.text, 12,
719 self.text = '''\
732 result = fill(self.text, 40)
742 result = wrap(self.text, 40, initial_indent=" ")
746 result = fill(self.text, 40, initial_indent=" ")
759 result = fill(self.text, 40,
768 def assertUnchanged(self, text):
769 """assert that dedent() has no effect on 'text'"""
770 self.assertEqual(text, dedent(text))
774 text = "Hello there.\nHow are you?\nOh good, I'm glad."
775 self.assertUnchanged(text)
778 text = "Hello there.\n\nBoo!"
779 self.assertUnchanged(text)
782 text = "Hello there.\n This is indented."
783 self.assertUnchanged(text)
786 text = "Hello there.\n\n Boo!\n"
787 self.assertUnchanged(text)
791 text = " Hello there.\n How are ya?\n Oh good."
793 self.assertEqual(expect, dedent(text))
796 text = " Hello there.\n\n How are ya?\n Oh good.\n"
798 self.assertEqual(expect, dedent(text))
801 text = " Hello there.\n \n How are ya?\n Oh good.\n"
803 self.assertEqual(expect, dedent(text))
807 text = '''\
817 self.assertEqual(expect, dedent(text))
820 text = " Foo\n Bar\n\n Baz\n"
822 self.assertEqual(expect, dedent(text))
825 text = " Foo\n Bar\n \n Baz\n"
827 self.assertEqual(expect, dedent(text))
831 text = " Foo\n Bar\n" # 5 spaces, then 4
833 self.assertEqual(expect, dedent(text))
836 text = " Foo\n\n Bar\n" # 5 spaces, blank, then 4
838 self.assertEqual(expect, dedent(text))
841 text = " Foo\n \n Bar\n" # 5 spaces, then 4, then 4
843 self.assertEqual(expect, dedent(text))
847 text = " hello\tthere\n how are\tyou?"
849 self.assertEqual(expect, dedent(text))
859 text = " hello there\n\thow are you?"
860 self.assertUnchanged(text)
863 text = " hello there\n\thow are you?"
864 self.assertUnchanged(text)
867 text = "\thello there\n\thow are you?"
869 self.assertEqual(expect, dedent(text))
871 text = " \thello there\n \thow are you?"
872 self.assertEqual(expect, dedent(text))
874 text = " \t hello there\n \t how are you?"
875 self.assertEqual(expect, dedent(text))
877 text = " \thello there\n \t how are you?"
879 self.assertEqual(expect, dedent(text))
882 text = " \thello there\n \thow are you?\n \tI'm fine, thanks"
884 self.assertEqual(expect, dedent(text))
910 for text in self.CASES:
911 self.assertEqual(indent(text, ''), text)
916 for text in self.CASES:
917 self.assertEqual(indent(text, '', None), text)
923 for text in self.CASES:
924 self.assertEqual(indent(text, '', predicate), text)
929 for text in self.CASES:
930 self.assertEqual(indent(text, ' ', predicate), text)
934 for text in self.ROUNDTRIP_CASES:
935 self.assertEqual(dedent(indent(text, ' ')), text)
939 for text in self.ROUNDTRIP_CASES:
940 self.assertEqual(dedent(indent(text, '\t\t')), text)
944 for text in self.ROUNDTRIP_CASES:
945 self.assertEqual(dedent(indent(text, ' \t \t ')), text)
962 for text, expect in zip(self.CASES, expected):
963 self.assertEqual(indent(text, prefix), expect)
980 for text, expect in zip(self.CASES, expected):
981 self.assertEqual(indent(text, prefix, None), expect)
999 for text, expect in zip(self.CASES, expected):
1000 self.assertEqual(indent(text, prefix, predicate), expect)
1018 for text, expect in zip(self.CASES, expected):
1019 self.assertEqual(indent(text, prefix, predicate), expect)
1024 def check_shorten(self, text, width, expect, **kwargs):
1025 result = shorten(text, width, **kwargs)
1030 text = "Hello there, how are you this fine day? I'm glad to hear it!"
1032 self.check_shorten(text, 18, "Hello there, [...]")
1033 self.check_shorten(text, len(text), text)
1034 self.check_shorten(text, len(text) - 1,
1039 text = "Hello there, how are you this fine day? I'm glad to hear it!"
1041 self.check_shorten(text, 17, "Hello there,$$", placeholder='$$')
1042 self.check_shorten(text, 18, "Hello there, how$$", placeholder='$$')
1043 self.check_shorten(text, 18, "Hello there, $$", placeholder=' $$')
1044 self.check_shorten(text, len(text), text, placeholder='$$')
1045 self.check_shorten(text, len(text) - 1,
1054 text = """
1057 self.check_shorten(text, 62,
1060 self.check_shorten(text, 61,