Kaydet (Commit) 214f7eed authored tarafından Jonathan Eunice's avatar Jonathan Eunice Kaydeden (comit) Mariatta

bpo-30603: add tests to textwrap.dedent (GH-2206)

* test dedent with declining indent level
* add textwrap.dedent test cases
üst 258bfc46
......@@ -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?"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment