mirror of
https://github.com/python/cpython
synced 2026-09-29 10:15:30 +03:00
bpo-30603: add tests to textwrap.dedent (GH-2206)
* test dedent with declining indent level * add textwrap.dedent test cases
This commit is contained in:
parent
258bfc462b
commit
214f7eed76
1 changed files with 11 additions and 0 deletions
|
|
@ -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?"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue