Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_textwrap.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 9fe76c26ea9f |
| children | 65e5f28801e1 d38e821c1b80 |
| 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 |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
47067
diff
changeset
|
12 from test import 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) |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
41993
diff
changeset
|
26 elif isinstance(textin, str): |
|
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): |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
32 self.assertEqual(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) |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
42 self.assertEqual(result, expect, |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
43 "\nexpected %r\n" |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
44 "but got %r" % (expect, result)) |
|
24968
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 |
|
46664
031dfe455585
Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44782
diff
changeset
|
132 text = 'File stdio.h is nice.' |
|
031dfe455585
Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44782
diff
changeset
|
133 expect = ['File stdio.h is nice.'] |
|
031dfe455585
Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44782
diff
changeset
|
134 self.check(wrapper.wrap(text), expect) |
|
031dfe455585
Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
44782
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 |
|
0725f0d5a5c7
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
Greg Ward <gward@python.net>
parents:
32538
diff
changeset
|
177 self.check_wrap(text, 30, ['Python 1.0.0 was released on', |
|
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 |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
335 def test_no_drop_whitespace(self): |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
336 # SF patch #1581073 |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
337 text = " This is a sentence with much whitespace." |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
338 self.check_wrap(text, 10, |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
339 [" This is a", " ", "sentence ", |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
340 "with ", "much white", "space."], |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
341 drop_whitespace=False) |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
342 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
343 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
|
344 # 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
|
345 # in the comments |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
346 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
347 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
|
348 |
|
24949
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
349 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
|
350 self.check(result, |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
351 ["Hello", " ", "there", " ", "--", " ", "you", " ", "goof-", |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
352 "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
|
353 |
|
47067
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
354 def test_break_on_hyphens(self): |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
355 # Ensure that the break_on_hyphens attributes work |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
356 text = "yaba daba-doo" |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
357 self.check_wrap(text, 10, ["yaba daba-", "doo"], |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
358 break_on_hyphens=True) |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
359 self.check_wrap(text, 10, ["yaba", "daba-doo"], |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
360 break_on_hyphens=False) |
|
960ade856078
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
Alexandre Vassalotti <alexandre@peadrop.com>
parents:
46664
diff
changeset
|
361 |
|
29004
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
362 def test_bad_width(self): |
|
a07def0dc785
SF #726446: ensure wrap() raises ValueError when width <= 0.
Greg Ward <gward@python.net>
parents:
28917
diff
changeset
|
363 # 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
|
364 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
|
365 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
|
366 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
|
367 |
|
50157
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
368 def test_no_split_at_umlaut(self): |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
369 text = "Die Empf\xe4nger-Auswahl" |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
370 self.check_wrap(text, 13, ["Die", "Empf\xe4nger-", "Auswahl"]) |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
371 |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
372 def test_umlaut_followed_by_dash(self): |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
373 text = "aa \xe4\xe4-\xe4\xe4" |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
374 self.check_wrap(text, 7, ["aa \xe4\xe4-", "\xe4\xe4"]) |
|
740ce9a523ff
Issue #4163: textwrap module: allow word splitting on a hyphen preceded by a non-ASCII letter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47201
diff
changeset
|
375 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
376 |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
377 class LongWordTestCase (BaseTestCase): |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
378 def setUp(self): |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
379 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
|
380 self.text = '''\ |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
381 Did you say "supercalifragilisticexpialidocious?" |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
382 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
|
383 ''' |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
384 |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
385 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
|
386 # 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
|
387 |
|
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
388 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
|
389 ['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
|
390 '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
|
391 '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
|
392 'anyways?']) |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
393 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
|
394 ['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
|
395 '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
|
396 |
|
30244
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
397 # 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
|
398 # 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
|
399 self.check_wrap('-'*10+'hello', 10, |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
400 ['----------', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
401 ' h', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
402 ' e', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
403 ' l', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
404 ' l', |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
405 ' o'], |
|
9e3d51bec53a
SF bug 797650: Infinite loop in textwrap.py
Raymond Hettinger <python@rcn.com>
parents:
29023
diff
changeset
|
406 subsequent_indent = ' '*15) |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
407 |
|
44782
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
408 # bug 1146. Prevent a long word to be wrongly wrapped when the |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
409 # preceding word is exactly one character shorter than the width |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
410 self.check_wrap(self.text, 12, |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
411 ['Did you say ', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
412 '"supercalifr', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
413 'agilisticexp', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
414 'ialidocious?', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
415 '" How *do*', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
416 'you spell', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
417 'that odd', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
418 'word,', |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
419 'anyways?']) |
|
ca2683a67943
Merged revisions 60080-60089,60091-60093 via svnmerge from
Georg Brandl <georg@python.org>
parents:
43577
diff
changeset
|
420 |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
421 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
|
422 # 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
|
423 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
|
424 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
|
425 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
|
426 '"supercalifragilisticexpialidocious?"', |
|
9f26e0c0c692
Ditch the whole loop-over-subcases way of working. Add check_wrap() to
Greg Ward <gward@python.net>
parents:
24948
diff
changeset
|
427 '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
|
428 'word, anyways?' |
|
24962
c1f682beebea
Standardize behavior: no docstrings in test functions. Also strip
Guido van Rossum <guido@python.org>
parents:
24958
diff
changeset
|
429 ] |
|
24951
1bcafbc69c96
Factor LongWordTestCase out of WrapTestCase, and rename its methods
Greg Ward <gward@python.net>
parents:
24950
diff
changeset
|
430 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
|
431 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
432 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
433 # 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
|
434 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
|
435 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
436 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
437 |
|
24950
13388cafc16e
Rename base test case class to (yawn) BaseTestCase.
Greg Ward <gward@python.net>
parents:
24949
diff
changeset
|
438 class IndentTestCases(BaseTestCase): |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
439 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
440 # 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
|
441 def setUp(self): |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
442 self.text = '''\ |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
443 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
|
444 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
|
445 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
446 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
447 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
|
448 # 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
|
449 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
450 expect = '''\ |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
451 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
|
452 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
|
453 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
|
454 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
455 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
|
456 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
457 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
458 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
459 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
|
460 # 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
|
461 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
462 expect = [" This paragraph will be filled,", |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
463 "first without any indentation, and then", |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
464 "with some (including a hanging indent)."] |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
465 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
|
466 self.check(result, expect) |
|
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 expect = "\n".join(expect) |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
469 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
|
470 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
471 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
472 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
473 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
|
474 # 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
|
475 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
476 expect = '''\ |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
477 * 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
|
478 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
|
479 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
|
480 indent).''' |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
481 |
|
24952
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
482 result = fill(self.text, 40, |
|
6a18b4e838ea
Simplification/cleanup in IndentTestCases.
Greg Ward <gward@python.net>
parents:
24951
diff
changeset
|
483 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
|
484 self.check(result, expect) |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
485 |
|
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
486 |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
487 # 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
|
488 # of IndentTestCase! |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
489 class DedentTestCase(unittest.TestCase): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
490 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
491 def assertUnchanged(self, text): |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
492 """assert that dedent() has no effect on 'text'""" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
493 self.assertEqual(text, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
494 |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
495 def test_dedent_nomargin(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
496 # No lines indented. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
497 text = "Hello there.\nHow are you?\nOh good, I'm glad." |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
498 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
499 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
500 # Similar, with a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
501 text = "Hello there.\n\nBoo!" |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
502 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
503 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
504 # 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
|
505 text = "Hello there.\n This is indented." |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
506 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
507 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
508 # Again, add a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
509 text = "Hello there.\n\n Boo!\n" |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
510 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
511 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
512 def test_dedent_even(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
513 # All lines indented by two spaces. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
514 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
|
515 expect = "Hello there.\nHow are ya?\nOh good." |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
516 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
517 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
518 # Same, with blank lines. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
519 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
|
520 expect = "Hello there.\n\nHow are ya?\nOh good.\n" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
521 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
522 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
523 # Now indent one of the blank lines. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
524 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
|
525 expect = "Hello there.\n\nHow are ya?\nOh good.\n" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
526 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
527 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
528 def test_dedent_uneven(self): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
529 # Lines indented unevenly. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
530 text = '''\ |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
531 def foo(): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
532 while 1: |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
533 return foo |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
534 ''' |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
535 expect = '''\ |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
536 def foo(): |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
537 while 1: |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
538 return foo |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
539 ''' |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
540 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
541 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
542 # Uneven indentation with a blank line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
543 text = " Foo\n Bar\n\n Baz\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
544 expect = "Foo\n Bar\n\n Baz\n" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
545 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
546 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
547 # Uneven indentation with a whitespace-only line. |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
548 text = " Foo\n Bar\n \n Baz\n" |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
549 expect = "Foo\n Bar\n\n Baz\n" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
550 self.assertEqual(expect, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
551 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
552 # dedent() should not mangle internal tabs |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
553 def test_dedent_preserve_internal_tabs(self): |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
554 text = " hello\tthere\n how are\tyou?" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
555 expect = "hello\tthere\nhow are\tyou?" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
556 self.assertEqual(expect, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
557 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
558 # make sure that it preserves tabs when it's not making any |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
559 # changes at all |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
560 self.assertEqual(expect, dedent(expect)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
561 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
562 # dedent() should not mangle tabs in the margin (i.e. |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
563 # tabs and spaces both count as margin, but are *not* |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
564 # considered equivalent) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
565 def test_dedent_preserve_margin_tabs(self): |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
566 text = " hello there\n\thow are you?" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
567 self.assertUnchanged(text) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
568 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
569 # same effect even if we have 8 spaces |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
570 text = " hello there\n\thow are you?" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
571 self.assertUnchanged(text) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
572 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
573 # dedent() only removes whitespace that can be uniformly removed! |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
574 text = "\thello there\n\thow are you?" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
575 expect = "hello there\nhow are you?" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
576 self.assertEqual(expect, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
577 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
578 text = " \thello there\n \thow are you?" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
579 self.assertEqual(expect, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
580 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
581 text = " \t hello there\n \t how are you?" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
582 self.assertEqual(expect, dedent(text)) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
583 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
584 text = " \thello there\n \t how are you?" |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
35309
diff
changeset
|
585 expect = "hello there\n how are you?" |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
50157
diff
changeset
|
586 self.assertEqual(expect, dedent(text)) |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
587 |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
588 |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
589 def test_main(): |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
47067
diff
changeset
|
590 support.run_unittest(WrapTestCase, |
|
29023
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
591 LongWordTestCase, |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
592 IndentTestCases, |
|
cb832c2cd54d
Add DedentTestCase to test dedent() function.
Greg Ward <gward@python.net>
parents:
29006
diff
changeset
|
593 DedentTestCase) |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
594 |
|
24945
7417a6dc7366
Test script for the textwrap module. Kindly provided by Peter Hansen
Greg Ward <gward@python.net>
parents:
diff
changeset
|
595 if __name__ == '__main__': |
|
24946
0c201548d3d4
Conform to standards documented in README:
Greg Ward <gward@python.net>
parents:
24945
diff
changeset
|
596 test_main() |
