whitespace is a substring of smallest leading whitespace.
Based on patch by Robert Li.
expect = "hello there\n how are you?"
self.assertEqual(expect, dedent(text))
+ # test margin is smaller than smallest indent
+ text = " \thello there\n \thow are you?\n \tI'm fine, thanks"
+ expect = " \thello there\n \thow are you?\n\tI'm fine, thanks"
+ self.assertEqual(expect, dedent(text))
+
# Test textwrap.indent
class IndentTestCase(unittest.TestCase):
elif margin.startswith(indent):
margin = indent
- # Current line and previous winner have no common whitespace:
- # there is no margin.
+ # Find the largest common whitespace between current line and previous
+ # winner.
else:
- margin = ""
- break
+ for i, (x, y) in enumerate(zip(margin, indent)):
+ if x != y:
+ margin = margin[:i]
+ break
+ else:
+ margin = margin[:len(indent)]
# sanity check (testing/debugging only)
if 0 and margin:
Ivan Levkivskyi
William Lewis
Akira Li
+Robert Li
Xuanji Li
Robert van Liere
Ross Light
Library
-------
+- Issue #21827: Fixed textwrap.dedent() for the case when largest common
+ whitespace is a substring of smallest leading whitespace.
+ Based on patch by Robert Li.
+
- Issue #25471: Sockets returned from accept() shouldn't appear to be
nonblocking.