Back to index

python3.2  3.2.2
Public Member Functions
test.test_textwrap.DedentTestCase Class Reference

List of all members.

Public Member Functions

def assertUnchanged
def test_dedent_nomargin
def test_dedent_even
def test_dedent_uneven
def test_dedent_preserve_internal_tabs
def test_dedent_preserve_margin_tabs

Detailed Description

Definition at line 489 of file test_textwrap.py.


Member Function Documentation

assert that dedent() has no effect on 'text'

Definition at line 491 of file test_textwrap.py.

00491 
00492     def assertUnchanged(self, text):
00493         """assert that dedent() has no effect on 'text'"""
00494         self.assertEqual(text, dedent(text))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 512 of file test_textwrap.py.

00512 
00513     def test_dedent_even(self):
00514         # All lines indented by two spaces.
00515         text = "  Hello there.\n  How are ya?\n  Oh good."
00516         expect = "Hello there.\nHow are ya?\nOh good."
00517         self.assertEqual(expect, dedent(text))
00518 
00519         # Same, with blank lines.
00520         text = "  Hello there.\n\n  How are ya?\n  Oh good.\n"
00521         expect = "Hello there.\n\nHow are ya?\nOh good.\n"
00522         self.assertEqual(expect, dedent(text))
00523 
00524         # Now indent one of the blank lines.
00525         text = "  Hello there.\n  \n  How are ya?\n  Oh good.\n"
00526         expect = "Hello there.\n\nHow are ya?\nOh good.\n"
00527         self.assertEqual(expect, dedent(text))

Here is the call graph for this function:

Definition at line 495 of file test_textwrap.py.

00495 
00496     def test_dedent_nomargin(self):
00497         # No lines indented.
00498         text = "Hello there.\nHow are you?\nOh good, I'm glad."
00499         self.assertUnchanged(text)
00500 
00501         # Similar, with a blank line.
00502         text = "Hello there.\n\nBoo!"
00503         self.assertUnchanged(text)
00504 
00505         # Some lines indented, but overall margin is still zero.
00506         text = "Hello there.\n  This is indented."
00507         self.assertUnchanged(text)
00508 
00509         # Again, add a blank line.
00510         text = "Hello there.\n\n  Boo!\n"
00511         self.assertUnchanged(text)

Here is the call graph for this function:

Definition at line 553 of file test_textwrap.py.

00553 
00554     def test_dedent_preserve_internal_tabs(self):
00555         text = "  hello\tthere\n  how are\tyou?"
00556         expect = "hello\tthere\nhow are\tyou?"
00557         self.assertEqual(expect, dedent(text))
00558 
00559         # make sure that it preserves tabs when it's not making any
00560         # changes at all
00561         self.assertEqual(expect, dedent(expect))

Here is the call graph for this function:

Definition at line 565 of file test_textwrap.py.

00565 
00566     def test_dedent_preserve_margin_tabs(self):
00567         text = "  hello there\n\thow are you?"
00568         self.assertUnchanged(text)
00569 
00570         # same effect even if we have 8 spaces
00571         text = "        hello there\n\thow are you?"
00572         self.assertUnchanged(text)
00573 
00574         # dedent() only removes whitespace that can be uniformly removed!
00575         text = "\thello there\n\thow are you?"
00576         expect = "hello there\nhow are you?"
00577         self.assertEqual(expect, dedent(text))
00578 
00579         text = "  \thello there\n  \thow are you?"
00580         self.assertEqual(expect, dedent(text))
00581 
00582         text = "  \t  hello there\n  \t  how are you?"
00583         self.assertEqual(expect, dedent(text))
00584 
00585         text = "  \thello there\n  \t  how are you?"
00586         expect = "hello there\n  how are you?"
00587         self.assertEqual(expect, dedent(text))
00588 

Here is the call graph for this function:

Definition at line 528 of file test_textwrap.py.

00528 
00529     def test_dedent_uneven(self):
00530         # Lines indented unevenly.
00531         text = '''\
00532         def foo():
00533             while 1:
00534                 return foo
00535         '''
00536         expect = '''\
00537 def foo():
00538     while 1:
00539         return foo
00540 '''
00541         self.assertEqual(expect, dedent(text))
00542 
00543         # Uneven indentation with a blank line.
00544         text = "  Foo\n    Bar\n\n   Baz\n"
00545         expect = "Foo\n  Bar\n\n Baz\n"
00546         self.assertEqual(expect, dedent(text))
00547 
00548         # Uneven indentation with a whitespace-only line.
00549         text = "  Foo\n    Bar\n \n   Baz\n"
00550         expect = "Foo\n  Bar\n\n Baz\n"
00551         self.assertEqual(expect, dedent(text))

Here is the call graph for this function:


The documentation for this class was generated from the following file: