Skip to content

Commit

Permalink
bpo-30603: add tests to textwrap.dedent (GH-2206)
Browse files Browse the repository at this point in the history
* test dedent with declining indent level
* add textwrap.dedent test cases
  • Loading branch information
jonathaneunice authored and Mariatta committed Jun 16, 2017
1 parent 258bfc4 commit 214f7ee
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lib/test/test_textwrap.py
Expand Up @@ -754,11 +754,22 @@ def foo():
expect = "Foo\n Bar\n\n Baz\n"
self.assertEqual(expect, dedent(text))

def test_dedent_declining(self):
# Uneven indentation with declining indent level.
text = " Foo\n Bar\n" # 5 spaces, then 4
expect = " Foo\nBar\n"
self.assertEqual(expect, dedent(text))

# Declining indent level with blank line.
text = " Foo\n\n Bar\n" # 5 spaces, blank, then 4
expect = " Foo\n\nBar\n"
self.assertEqual(expect, dedent(text))

# Declining indent level with whitespace only line.
text = " Foo\n \n Bar\n" # 5 spaces, then 4, then 4
expect = " Foo\n\nBar\n"
self.assertEqual(expect, dedent(text))

# dedent() should not mangle internal tabs
def test_dedent_preserve_internal_tabs(self):
text = " hello\tthere\n how are\tyou?"
Expand Down

0 comments on commit 214f7ee

Please sign in to comment.