]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30603: add tests to textwrap.dedent (GH-2206)
authorJonathan Eunice <jonathan.eunice@gmail.com>
Fri, 16 Jun 2017 02:18:54 +0000 (22:18 -0400)
committerMariatta <Mariatta@users.noreply.github.com>
Fri, 16 Jun 2017 02:18:54 +0000 (19:18 -0700)
* test dedent with declining indent level
* add textwrap.dedent test cases

Lib/test/test_textwrap.py

index fe15348aff114bd2ae839cda1cedc217967e435b..ed97f70ba1fa40e829c3a8d1a6387ac631c6f1a7 100644 (file)
@@ -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?"