diff options
author | Jonathan Eunice <jonathan.eunice@gmail.com> | 2017-06-16 02:18:54 (GMT) |
---|---|---|
committer | Mariatta <Mariatta@users.noreply.github.com> | 2017-06-16 02:18:54 (GMT) |
commit | 214f7eed7640f873223427c02a95a70775d2b396 (patch) | |
tree | 9c09515bd12e5afd8d088c16c831ce75414808e1 | |
parent | 258bfc462b1e58689b43f662a10e44ece3a10bef (diff) | |
download | cpython-214f7eed7640f873223427c02a95a70775d2b396.zip cpython-214f7eed7640f873223427c02a95a70775d2b396.tar.gz cpython-214f7eed7640f873223427c02a95a70775d2b396.tar.bz2 |
bpo-30603: add tests to textwrap.dedent (GH-2206)
* test dedent with declining indent level
* add textwrap.dedent test cases
-rw-r--r-- | Lib/test/test_textwrap.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index fe15348..ed97f70 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -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?" |