Fix an endcase bug: initial_indent was ignored when the text was short
enough to fit in one line.
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index fc5d0cc..2a6d67a 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -33,11 +33,11 @@
'expected:\n%s\nbut got:\n%s' % (
self.show(expect), self.show(result)))
- def check_wrap (self, text, width, expect):
- result = wrap(text, width)
+ def check_wrap(self, text, width, expect, **kwargs):
+ result = wrap(text, width, **kwargs)
self.check(result, expect)
- def check_split (self, wrapper, text, expect):
+ def check_split(self, wrapper, text, expect):
result = wrapper._split(text)
self.assertEquals(result, expect,
"\nexpected %r\n"
@@ -101,6 +101,16 @@
self.check_wrap(text, 40, ["This is a short paragraph."])
+ def test_wrap_short_1line(self):
+ # Test endcases
+
+ text = "This is a short line."
+
+ self.check_wrap(text, 30, ["This is a short line."])
+ self.check_wrap(text, 30, ["(1) This is a short line."],
+ initial_indent="(1) ")
+
+
def test_hyphenated(self):
# Test breaking hyphenated words