Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_textwrap.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | e4675113d10e |
| children | 6ffcdafa0118 |
| rev | line source |
|---|---|
| 24947 | 1 # |
|
32210
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
2 # Test suite for the textwrap module. |
| 24947 | 3 # |
| 4 # Original tests written by Greg Ward <gward@python.net>. | |
| 5 # Converted to PyUnit by Peter Hansen <peter@engcorp.com>. | |
| 6 # Currently maintained by Greg Ward. | |
| 7 # | |
| 8 # $Id$ | |
| 9 # | |
| 10 | |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
11 import unittest |
|
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
12 from test import test_support |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
13 |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
14 from textwrap import TextWrapper, wrap, fill, dedent |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
16 |
|
24950
13388cafc16e
Rename base test case class to (yawn) BaseTestCase.
Greg Ward <gward@python.net>
parents:
24949
diff
changeset
|
17 class BaseTestCase(unittest.TestCase): |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
18 '''Parent class with utility methods for textwrap tests.''' |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
19 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
20 def show(self, textin): |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
21 if isinstance(textin, list): |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
22 result = [] |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
23 for i in range(len(textin)): |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
24 result.append(" %d: %r" % (i, textin[i])) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
25 result = '\n'.join(result) |
|
30448
7cb6745be525
SF patch #806246: use basestring where possible
Raymond Hettinger <python@rcn.com>
parents:
30244
diff
changeset
|
26 elif isinstance(textin, basestring): |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
27 result = " %s\n" % repr(textin) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
28 return result |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
29 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
30 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
31 def check(self, result, expect): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
32 self.assertEquals(result, expect, |
|
24958
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
33 'expected:\n%s\nbut got:\n%s' % ( |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
34 self.show(expect), self.show(result))) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
35 |
|
25534
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
36 def check_wrap(self, text, width, expect, **kwargs): |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
37 result = wrap(text, width, **kwargs) |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
38 self.check(result, expect) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
39 |
|
25977
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
40 def check_split(self, text, expect): |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
41 result = self.wrapper._split(text) |
|
24968
95186591cbcf
Factored out BaseTestCase.check_split() method -- use it wherever
Greg Ward <gward@python.net>
parents:
24967
diff
changeset
|
42 self.assertEquals(result, expect, |
|
95186591cbcf
Factored out BaseTestCase.check_split() method -- use it wherever
Greg Ward <gward@python.net>
parents:
24967
diff
changeset
|
43 "\nexpected %r\n" |
|
95186591cbcf
Factored out BaseTestCase.check_split() method -- use it wherever
Greg Ward <gward@python.net>
parents:
24967
diff
changeset
|
44 "but got %r" % (expect, result)) |
|
95186591cbcf
Factored out BaseTestCase.check_split() method -- use it wherever
Greg Ward <gward@python.net>
parents:
24967
diff
changeset
|
45 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
46 |
|
24950
13388cafc16e
Rename base test case class to (yawn) BaseTestCase.
Greg Ward <gward@python.net>
parents:
24949
diff
changeset
|
47 class WrapTestCase(BaseTestCase): |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
48 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
49 def setUp(self): |
|
32088
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
50 self.wrapper = TextWrapper(width=45) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
51 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
52 def test_simple(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
53 # Simple case: just words, spaces, and a bit of punctuation |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
54 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
55 text = "Hello there, how are you this fine day? I'm glad to hear it!" |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
56 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
57 self.check_wrap(text, 12, |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
58 ["Hello there,", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
59 "how are you", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
60 "this fine", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
61 "day? I'm", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
62 "glad to hear", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
63 "it!"]) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
64 self.check_wrap(text, 42, |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
65 ["Hello there, how are you this fine day?", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
66 "I'm glad to hear it!"]) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
67 self.check_wrap(text, 80, [text]) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
68 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
69 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
70 def test_whitespace(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
71 # Whitespace munging and end-of-sentence detection |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
72 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
73 text = """\ |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
74 This is a paragraph that already has |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
75 line breaks. But some of its lines are much longer than the others, |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
76 so it needs to be wrapped. |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
77 Some lines are \ttabbed too. |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
78 What a mess! |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
79 """ |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
80 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
81 expect = ["This is a paragraph that already has line", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
82 "breaks. But some of its lines are much", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
83 "longer than the others, so it needs to be", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
84 "wrapped. Some lines are tabbed too. What a", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
85 "mess!"] |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
86 |
|
32088
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
87 wrapper = TextWrapper(45, fix_sentence_endings=True) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
88 result = wrapper.wrap(text) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
89 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
90 |
|
32088
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
91 result = wrapper.fill(text) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
92 self.check(result, '\n'.join(expect)) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
93 |
|
32088
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
94 def test_fix_sentence_endings(self): |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
95 wrapper = TextWrapper(60, fix_sentence_endings=True) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
96 |
|
32088
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
97 # SF #847346: ensure that fix_sentence_endings=True does the |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
98 # right thing even on input short enough that it doesn't need to |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
99 # be wrapped. |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
100 text = "A short line. Note the single space." |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
101 expect = ["A short line. Note the single space."] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
102 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
103 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
104 # Test some of the hairy end cases that _fix_sentence_endings() |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
105 # is supposed to handle (the easy stuff is tested in |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
106 # test_whitespace() above). |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
107 text = "Well, Doctor? What do you think?" |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
108 expect = ["Well, Doctor? What do you think?"] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
109 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
110 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
111 text = "Well, Doctor?\nWhat do you think?" |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
112 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
113 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
114 text = 'I say, chaps! Anyone for "tennis?"\nHmmph!' |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
115 expect = ['I say, chaps! Anyone for "tennis?" Hmmph!'] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
116 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
117 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
118 wrapper.width = 20 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
119 expect = ['I say, chaps!', 'Anyone for "tennis?"', 'Hmmph!'] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
120 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
121 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
122 text = 'And she said, "Go to hell!"\nCan you believe that?' |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
123 expect = ['And she said, "Go to', |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
124 'hell!" Can you', |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
125 'believe that?'] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
126 self.check(wrapper.wrap(text), expect) |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
127 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
128 wrapper.width = 60 |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
129 expect = ['And she said, "Go to hell!" Can you believe that?'] |
|
52fe93b656cf
SF #847346: merge from release23-maint branch: remove misguided
Greg Ward <gward@python.net>
parents:
30448
diff
changeset
|
130 self.check(wrapper.wrap(text), expect) |
|
32538
4fab4a5cce2f
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
32210
diff
changeset
|
131 |
|
46561
9e05f15f921b
Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
Mark Dickinson <dickinsm@gmail.com>
parents:
44781
diff
changeset
|
132 text = 'File stdio.h is nice.' |
|
9e05f15f921b
Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
Mark Dickinson <dickinsm@gmail.com>
parents:
44781
diff
changeset
|
133 expect = ['File stdio.h is nice.'] |
|
9e05f15f921b
Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
Mark Dickinson <dickinsm@gmail.com>
parents:
44781
diff
changeset
|
134 self.check(wrapper.wrap(text), expect) |
|
9e05f15f921b
Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
Mark Dickinson <dickinsm@gmail.com>
parents:
44781
diff
changeset
|
135 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
136 def test_wrap_short(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
137 # Wrapping to make short lines longer |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
138 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
139 text = "This is a\nshort paragraph." |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
140 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
141 self.check_wrap(text, 20, ["This is a short", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
142 "paragraph."]) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
143 self.check_wrap(text, 40, ["This is a short paragraph."]) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
144 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
145 |
|
25534
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
146 def test_wrap_short_1line(self): |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
147 # Test endcases |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
148 |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
149 text = "This is a short line." |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
150 |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
151 self.check_wrap(text, 30, ["This is a short line."]) |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
152 self.check_wrap(text, 30, ["(1) This is a short line."], |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
153 initial_indent="(1) ") |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
154 |
|
08148e916d38
Fix an endcase bug: initial_indent was ignored when the text was short
Guido van Rossum <guido@python.org>
parents:
24969
diff
changeset
|
155 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
156 def test_hyphenated(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
157 # Test breaking hyphenated words |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
158 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
159 text = ("this-is-a-useful-feature-for-" |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
160 "reformatting-posts-from-tim-peters'ly") |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
161 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
162 self.check_wrap(text, 40, |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
163 ["this-is-a-useful-feature-for-", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
164 "reformatting-posts-from-tim-peters'ly"]) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
165 self.check_wrap(text, 41, |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
166 ["this-is-a-useful-feature-for-", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
167 "reformatting-posts-from-tim-peters'ly"]) |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
168 self.check_wrap(text, 42, |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
169 ["this-is-a-useful-feature-for-reformatting-", |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
170 "posts-from-tim-peters'ly"]) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
171 |
|
34691
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
172 def test_hyphenated_numbers(self): |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
173 # Test that hyphenated numbers (eg. dates) are not broken like words. |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
174 text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n" |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
175 "released on 1994-02-15.") |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
176 |
|
50257
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
177 self.check_wrap(text, 35, ['Python 1.0.0 was released on', |
|
34691
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
178 '1994-01-26. Python 1.0.1 was', |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
179 'released on 1994-02-15.']) |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
180 self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.', |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
181 'Python 1.0.1 was released on 1994-02-15.']) |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
182 |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
183 text = "I do all my shopping at 7-11." |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
184 self.check_wrap(text, 25, ["I do all my shopping at", |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
185 "7-11."]) |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
186 self.check_wrap(text, 27, ["I do all my shopping at", |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
187 "7-11."]) |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
188 self.check_wrap(text, 29, ["I do all my shopping at 7-11."]) |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
189 |
|
24958
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
190 def test_em_dash(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
191 # Test text with em-dashes |
|
24958
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
192 text = "Em-dashes should be written -- thus." |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
193 self.check_wrap(text, 25, |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
194 ["Em-dashes should be", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
195 "written -- thus."]) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
196 |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
197 # Probe the boundaries of the properly written em-dash, |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
198 # ie. " -- ". |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
199 self.check_wrap(text, 29, |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
200 ["Em-dashes should be written", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
201 "-- thus."]) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
202 expect = ["Em-dashes should be written --", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
203 "thus."] |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
204 self.check_wrap(text, 30, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
205 self.check_wrap(text, 35, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
206 self.check_wrap(text, 36, |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
207 ["Em-dashes should be written -- thus."]) |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
208 |
|
24958
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
209 # The improperly written em-dash is handled too, because |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
210 # it's adjacent to non-whitespace on both sides. |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
211 text = "You can also do--this or even---this." |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
212 expect = ["You can also do", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
213 "--this or even", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
214 "---this."] |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
215 self.check_wrap(text, 15, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
216 self.check_wrap(text, 16, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
217 expect = ["You can also do--", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
218 "this or even---", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
219 "this."] |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
220 self.check_wrap(text, 17, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
221 self.check_wrap(text, 19, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
222 expect = ["You can also do--this or even", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
223 "---this."] |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
224 self.check_wrap(text, 29, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
225 self.check_wrap(text, 31, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
226 expect = ["You can also do--this or even---", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
227 "this."] |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
228 self.check_wrap(text, 32, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
229 self.check_wrap(text, 35, expect) |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
230 |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
231 # All of the above behaviour could be deduced by probing the |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
232 # _split() method. |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
233 text = "Here's an -- em-dash and--here's another---and another!" |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
234 expect = ["Here's", " ", "an", " ", "--", " ", "em-", "dash", " ", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
235 "and", "--", "here's", " ", "another", "---", |
|
6e78a54bac3c
Add test_em_dash() to WrapTestCase to make sure that TextWrapper handles
Greg Ward <gward@python.net>
parents:
24952
diff
changeset
|
236 "and", " ", "another!"] |
|
25977
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
237 self.check_split(text, expect) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
238 |
|
24969
81679ebec07d
Test an em-dash with adjacent punctuation.
Greg Ward <gward@python.net>
parents:
24968
diff
changeset
|
239 text = "and then--bam!--he was gone" |
|
81679ebec07d
Test an em-dash with adjacent punctuation.
Greg Ward <gward@python.net>
parents:
24968
diff
changeset
|
240 expect = ["and", " ", "then", "--", "bam!", "--", |
|
81679ebec07d
Test an em-dash with adjacent punctuation.
Greg Ward <gward@python.net>
parents:
24968
diff
changeset
|
241 "he", " ", "was", " ", "gone"] |
|
25977
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
242 self.check_split(text, expect) |
|
24969
81679ebec07d
Test an em-dash with adjacent punctuation.
Greg Ward <gward@python.net>
parents:
24968
diff
changeset
|
243 |
|
81679ebec07d
Test an em-dash with adjacent punctuation.
Greg Ward <gward@python.net>
parents:
24968
diff
changeset
|
244 |
|
24966
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
245 def test_unix_options (self): |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
246 # Test that Unix-style command-line options are wrapped correctly. |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
247 # Both Optik (OptionParser) and Docutils rely on this behaviour! |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
248 |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
249 text = "You should use the -n option, or --dry-run in its long form." |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
250 self.check_wrap(text, 20, |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
251 ["You should use the", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
252 "-n option, or --dry-", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
253 "run in its long", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
254 "form."]) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
255 self.check_wrap(text, 21, |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
256 ["You should use the -n", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
257 "option, or --dry-run", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
258 "in its long form."]) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
259 expect = ["You should use the -n option, or", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
260 "--dry-run in its long form."] |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
261 self.check_wrap(text, 32, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
262 self.check_wrap(text, 34, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
263 self.check_wrap(text, 35, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
264 self.check_wrap(text, 38, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
265 expect = ["You should use the -n option, or --dry-", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
266 "run in its long form."] |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
267 self.check_wrap(text, 39, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
268 self.check_wrap(text, 41, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
269 expect = ["You should use the -n option, or --dry-run", |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
270 "in its long form."] |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
271 self.check_wrap(text, 42, expect) |
|
c45b28658805
Add test_unix_options() to WrapTestCase to test for SF bug #596434.
Greg Ward <gward@python.net>
parents:
24962
diff
changeset
|
272 |
|
24967
80f65c63e860
Test _split() method in test_unix_options().
Greg Ward <gward@python.net>
parents:
24966
diff
changeset
|
273 # Again, all of the above can be deduced from _split(). |
|
80f65c63e860
Test _split() method in test_unix_options().
Greg Ward <gward@python.net>
parents:
24966
diff
changeset
|
274 text = "the -n option, or --dry-run or --dryrun" |
|
80f65c63e860
Test _split() method in test_unix_options().
Greg Ward <gward@python.net>
parents:
24966
diff
changeset
|
275 expect = ["the", " ", "-n", " ", "option,", " ", "or", " ", |
|
80f65c63e860
Test _split() method in test_unix_options().
Greg Ward <gward@python.net>
parents:
24966
diff
changeset
|
276 "--dry-", "run", " ", "or", " ", "--dryrun"] |
|
25977
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
277 self.check_split(text, expect) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
278 |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
279 def test_funky_hyphens (self): |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
280 # Screwy edge cases cooked up by David Goodger. All reported |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
281 # in SF bug #596434. |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
282 self.check_split("what the--hey!", ["what", " ", "the", "--", "hey!"]) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
283 self.check_split("what the--", ["what", " ", "the--"]) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
284 self.check_split("what the--.", ["what", " ", "the--."]) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
285 self.check_split("--text--.", ["--text--."]) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
286 |
|
29006
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
287 # When I first read bug #596434, this is what I thought David |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
288 # was talking about. I was wrong; these have always worked |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
289 # fine. The real problem is tested in test_funky_parens() |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
290 # below... |
|
25977
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
291 self.check_split("--option", ["--option"]) |
|
1d02b405e31f
Ad test_funky_hyphens() to test some screwy edge cases reported in SF
Greg Ward <gward@python.net>
parents:
25534
diff
changeset
|
292 self.check_split("--option-opt", ["--option-", "opt"]) |
|
29006
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
293 self.check_split("foo --option-opt bar", |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
294 ["foo", " ", "--option-", "opt", " ", "bar"]) |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
295 |
|
32210
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
296 def test_punct_hyphens(self): |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
297 # Oh bother, SF #965425 found another problem with hyphens -- |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
298 # hyphenated words in single quotes weren't handled correctly. |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
299 # In fact, the bug is that *any* punctuation around a hyphenated |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
300 # word was handled incorrectly, except for a leading "--", which |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
301 # was special-cased for Optik and Docutils. So test a variety |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
302 # of styles of punctuation around a hyphenated word. |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
303 # (Actually this is based on an Optik bug report, #813077). |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
304 self.check_split("the 'wibble-wobble' widget", |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
305 ['the', ' ', "'wibble-", "wobble'", ' ', 'widget']) |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
306 self.check_split('the "wibble-wobble" widget', |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
307 ['the', ' ', '"wibble-', 'wobble"', ' ', 'widget']) |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
308 self.check_split("the (wibble-wobble) widget", |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
309 ['the', ' ', "(wibble-", "wobble)", ' ', 'widget']) |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
310 self.check_split("the ['wibble-wobble'] widget", |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
311 ['the', ' ', "['wibble-", "wobble']", ' ', 'widget']) |
|
eb41a489cc2f
SF #965425: fix so hyphenated words surrounded by punctuation are
Greg Ward <gward@python.net>
parents:
32088
diff
changeset
|
312 |
|
29006
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
313 def test_funky_parens (self): |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
314 # Second part of SF bug #596434: long option strings inside |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
315 # parentheses. |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
316 self.check_split("foo (--option) bar", |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
317 ["foo", " ", "(--option)", " ", "bar"]) |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
318 |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
319 # Related stuff -- make sure parens work in simpler contexts. |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
320 self.check_split("foo (bar) baz", |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
321 ["foo", " ", "(bar)", " ", "baz"]) |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
322 self.check_split("blah (ding dong), wubba", |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
323 ["blah", " ", "(ding", " ", "dong),", |
|
f9e6f9fb8df0
SF #596434: add test_funky_parens() to probe some more of the tricky
Greg Ward <gward@python.net>
parents:
29004
diff
changeset
|
324 " ", "wubba"]) |
|
24967
80f65c63e860
Test _split() method in test_unix_options().
Greg Ward <gward@python.net>
parents:
24966
diff
changeset
|
325 |
|
26581
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
326 def test_initial_whitespace(self): |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
327 # SF bug #622849 reported inconsistent handling of leading |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
328 # whitespace; let's test that a bit, shall we? |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
329 text = " This is a sentence with leading whitespace." |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
330 self.check_wrap(text, 50, |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
331 [" This is a sentence with leading whitespace."]) |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
332 self.check_wrap(text, 30, |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
333 [" This is a sentence with", "leading whitespace."]) |
|
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
334 |
|
41158
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
335 def test_no_drop_whitespace(self): |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
336 # SF patch #1581073 |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
337 text = " This is a sentence with much whitespace." |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
338 self.check_wrap(text, 10, |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
339 [" This is a", " ", "sentence ", |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
340 "with ", "much white", "space."], |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
341 drop_whitespace=False) |
|
1d80d84c7792
Patch #1581073: add a flag to textwrap that prevents the dropping of
Georg Brandl <georg@python.org>
parents:
38748
diff
changeset
|
342 |
|
35309
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
343 if test_support.have_unicode: |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
344 def test_unicode(self): |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
345 # *Very* simple test of wrapping Unicode strings. I'm sure |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
346 # there's more to it than this, but let's at least make |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
347 # sure textwrap doesn't crash on Unicode input! |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
348 text = u"Hello there, how are you today?" |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
349 self.check_wrap(text, 50, [u"Hello there, how are you today?"]) |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
350 self.check_wrap(text, 20, [u"Hello there, how are", "you today?"]) |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
351 olines = self.wrapper.wrap(text) |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
352 assert isinstance(olines, list) and isinstance(olines[0], unicode) |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
353 otext = self.wrapper.fill(text) |
|
5fe9ceeca111
Disable a few other tests, that can't work if Python is compiled without
Walter Dörwald <walter@livinglogic.de>
parents:
34691
diff
changeset
|
354 assert isinstance(otext, unicode) |
|
26582
952687ea9cb1
Add test_unicode() to ensure that 1) textwrap doesn't crash on unicode
Greg Ward <gward@python.net>
parents:
26581
diff
changeset
|
355 |
|
50257
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
356 def test_no_split_at_umlaut(self): |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
357 text = u"Die Empf\xe4nger-Auswahl" |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
358 self.check_wrap(text, 13, [u"Die", u"Empf\xe4nger-", u"Auswahl"]) |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
359 |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
360 def test_umlaut_followed_by_dash(self): |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
361 text = u"aa \xe4\xe4-\xe4\xe4" |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
362 self.check_wrap(text, 7, [u"aa \xe4\xe4-", u"\xe4\xe4"]) |
|
e4675113d10e
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
46874
diff
changeset
|
363 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
364 def test_split(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
365 # Ensure that the standard _split() method works as advertised |
|
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
366 # in the comments |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
367 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
368 text = "Hello there -- you goof-ball, use the -b option!" |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
369 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
370 result = self.wrapper._split(text) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
371 self.check(result, |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
372 ["Hello", " ", "there", " ", "--", " ", "you", " ", "goof-", |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
373 "ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"]) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
374 |
|
46874
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
375 def test_break_on_hyphens(self): |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
376 # Ensure that the break_on_hyphens attributes work |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
377 text = "yaba daba-doo" |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
378 self.check_wrap(text, 10, ["yaba daba-", "doo"], |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
379 break_on_hyphens=True) |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
380 self.check_wrap(text, 10, ["yaba", "daba-doo"], |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
381 break_on_hyphens=False) |
|
c7d1a170c94c
#2659: add ``break_on_hyphens`` to TextWrapper.
Georg Brandl <georg@python.org>
parents:
46561
diff
changeset
|
382 |
|
29004
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
383 def test_bad_width(self): |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
384 # Ensure that width <= 0 is caught. |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
385 text = "Whatever, it doesn't matter." |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
386 self.assertRaises(ValueError, wrap, text, 0) |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
387 self.assertRaises(ValueError, wrap, text, -1) |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
388 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
389 |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
390 class LongWordTestCase (BaseTestCase): |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
391 def setUp(self): |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
392 self.wrapper = TextWrapper() |
|
26581
9206b004f152
Added test_initial_whitespace() to ensure that SF bug #622849 is fixed.
Greg Ward <gward@python.net>
parents:
25977
diff
changeset
|
393 self.text = '''\ |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
394 Did you say "supercalifragilisticexpialidocious?" |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
395 How *do* you spell that odd word, anyways? |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
396 ''' |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
397 |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
398 def test_break_long(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
399 # Wrap text with long words and lots of punctuation |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
400 |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
401 self.check_wrap(self.text, 30, |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
402 ['Did you say "supercalifragilis', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
403 'ticexpialidocious?" How *do*', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
404 'you spell that odd word,', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
405 'anyways?']) |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
406 self.check_wrap(self.text, 50, |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
407 ['Did you say "supercalifragilisticexpialidocious?"', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
408 'How *do* you spell that odd word, anyways?']) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
409 |
|
30244
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
410 # SF bug 797650. Prevent an infinite loop by making sure that at |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
411 # least one character gets split off on every pass. |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
412 self.check_wrap('-'*10+'hello', 10, |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
413 ['----------', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
414 ' h', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
415 ' e', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
416 ' l', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
417 ' l', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
418 ' o'], |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
419 subsequent_indent = ' '*15) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
420 |
|
44781
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
421 # bug 1146. Prevent a long word to be wrongly wrapped when the |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
422 # preceding word is exactly one character shorter than the width |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
423 self.check_wrap(self.text, 12, |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
424 ['Did you say ', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
425 '"supercalifr', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
426 'agilisticexp', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
427 'ialidocious?', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
428 '" How *do*', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
429 'you spell', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
430 'that odd', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
431 'word,', |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
432 'anyways?']) |
|
17009d6211b8
Fix #1146: TextWrap vs words 1-character shorter than the width.
Georg Brandl <georg@python.org>
parents:
41158
diff
changeset
|
433 |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
434 def test_nobreak_long(self): |
|
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
435 # Test with break_long_words disabled |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
436 self.wrapper.break_long_words = 0 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
437 self.wrapper.width = 30 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
438 expect = ['Did you say', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
439 '"supercalifragilisticexpialidocious?"', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
440 'How *do* you spell that odd', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
441 'word, anyways?' |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
442 ] |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
443 result = self.wrapper.wrap(self.text) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
444 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
445 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
446 # Same thing with kwargs passed to standalone wrap() function. |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
447 result = wrap(self.text, width=30, break_long_words=0) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
448 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
449 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
450 |
|
24950
13388cafc16e
Rename base test case class to (yawn) BaseTestCase.
Greg Ward <gward@python.net>
parents:
24949
diff
changeset
|
451 class IndentTestCases(BaseTestCase): |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
452 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
453 # called before each test method |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
454 def setUp(self): |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
455 self.text = '''\ |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
456 This paragraph will be filled, first without any indentation, |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
457 and then with some (including a hanging indent).''' |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
458 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
459 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
460 def test_fill(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
461 # Test the fill() method |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
462 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
463 expect = '''\ |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
464 This paragraph will be filled, first |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
465 without any indentation, and then with |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
466 some (including a hanging indent).''' |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
467 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
468 result = fill(self.text, 40) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
469 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
470 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
471 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
472 def test_initial_indent(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
473 # Test initial_indent parameter |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
474 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
475 expect = [" This paragraph will be filled,", |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
476 "first without any indentation, and then", |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
477 "with some (including a hanging indent)."] |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
478 result = wrap(self.text, 40, initial_indent=" ") |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
479 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
480 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
481 expect = "\n".join(expect) |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
482 result = fill(self.text, 40, initial_indent=" ") |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
483 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
484 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
485 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
486 def test_subsequent_indent(self): |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
487 # Test subsequent_indent parameter |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
488 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
489 expect = '''\ |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
490 * This paragraph will be filled, first |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
491 without any indentation, and then |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
492 with some (including a hanging |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
493 indent).''' |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
494 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
495 result = fill(self.text, 40, |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
496 initial_indent=" * ", subsequent_indent=" ") |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
497 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
498 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
499 |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
500 # Despite the similar names, DedentTestCase is *not* the inverse |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
501 # of IndentTestCase! |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
502 class DedentTestCase(unittest.TestCase): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
503 |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
504 def assertUnchanged(self, text): |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
505 """assert that dedent() has no effect on 'text'""" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
506 self.assertEquals(text, dedent(text)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
507 |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
508 def test_dedent_nomargin(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
509 # No lines indented. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
510 text = "Hello there.\nHow are you?\nOh good, I'm glad." |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
511 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
512 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
513 # Similar, with a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
514 text = "Hello there.\n\nBoo!" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
515 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
516 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
517 # Some lines indented, but overall margin is still zero. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
518 text = "Hello there.\n This is indented." |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
519 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
520 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
521 # Again, add a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
522 text = "Hello there.\n\n Boo!\n" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
523 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
524 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
525 def test_dedent_even(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
526 # All lines indented by two spaces. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
527 text = " Hello there.\n How are ya?\n Oh good." |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
528 expect = "Hello there.\nHow are ya?\nOh good." |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
529 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
530 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
531 # Same, with blank lines. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
532 text = " Hello there.\n\n How are ya?\n Oh good.\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
533 expect = "Hello there.\n\nHow are ya?\nOh good.\n" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
534 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
535 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
536 # Now indent one of the blank lines. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
537 text = " Hello there.\n \n How are ya?\n Oh good.\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
538 expect = "Hello there.\n\nHow are ya?\nOh good.\n" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
539 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
540 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
541 def test_dedent_uneven(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
542 # Lines indented unevenly. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
543 text = '''\ |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
544 def foo(): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
545 while 1: |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
546 return foo |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
547 ''' |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
548 expect = '''\ |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
549 def foo(): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
550 while 1: |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
551 return foo |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
552 ''' |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
553 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
554 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
555 # Uneven indentation with a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
556 text = " Foo\n Bar\n\n Baz\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
557 expect = "Foo\n Bar\n\n Baz\n" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
558 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
559 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
560 # Uneven indentation with a whitespace-only line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
561 text = " Foo\n Bar\n \n Baz\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
562 expect = "Foo\n Bar\n\n Baz\n" |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
563 self.assertEquals(expect, dedent(text)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
564 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
565 # dedent() should not mangle internal tabs |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
566 def test_dedent_preserve_internal_tabs(self): |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
567 text = " hello\tthere\n how are\tyou?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
568 expect = "hello\tthere\nhow are\tyou?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
569 self.assertEquals(expect, dedent(text)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
570 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
571 # make sure that it preserves tabs when it's not making any |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
572 # changes at all |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
573 self.assertEquals(expect, dedent(expect)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
574 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
575 # dedent() should not mangle tabs in the margin (i.e. |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
576 # tabs and spaces both count as margin, but are *not* |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
577 # considered equivalent) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
578 def test_dedent_preserve_margin_tabs(self): |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
579 text = " hello there\n\thow are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
580 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
581 |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
582 # same effect even if we have 8 spaces |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
583 text = " hello there\n\thow are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
584 self.assertUnchanged(text) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
585 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
586 # dedent() only removes whitespace that can be uniformly removed! |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
587 text = "\thello there\n\thow are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
588 expect = "hello there\nhow are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
589 self.assertEquals(expect, dedent(text)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
590 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
591 text = " \thello there\n \thow are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
592 self.assertEquals(expect, dedent(text)) |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
593 |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
594 text = " \t hello there\n \t how are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
595 self.assertEquals(expect, dedent(text)) |
|
38748
b50ab288ae27
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
38734
diff
changeset
|
596 |
|
38734
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
597 text = " \thello there\n \t how are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
598 expect = "hello there\n how are you?" |
|
9d8478f732d5
Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
Greg Ward <gward@python.net>
parents:
35309
diff
changeset
|
599 self.assertEquals(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
600 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
601 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
602 def test_main(): |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
603 test_support.run_unittest(WrapTestCase, |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
604 LongWordTestCase, |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
605 IndentTestCases, |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
606 DedentTestCase) |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
607 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
608 if __name__ == '__main__': |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
609 test_main() |
