Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_textwrap.LongWordTestCase Class Reference
Inheritance diagram for test.test_textwrap.LongWordTestCase:
Inheritance graph
[legend]
Collaboration diagram for test.test_textwrap.LongWordTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_break_long
def test_nobreak_long
def show
def check
def check_wrap
def check_split

Public Attributes

 wrapper
 text

Detailed Description

Definition at line 377 of file test_textwrap.py.


Member Function Documentation

def test.test_textwrap.BaseTestCase.check (   self,
  result,
  expect 
) [inherited]

Definition at line 31 of file test_textwrap.py.

00031 
00032     def check(self, result, expect):
00033         self.assertEqual(result, expect,
00034             'expected:\n%s\nbut got:\n%s' % (
00035                 self.show(expect), self.show(result)))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_textwrap.BaseTestCase.check_split (   self,
  text,
  expect 
) [inherited]

Definition at line 40 of file test_textwrap.py.

00040 
00041     def check_split(self, text, expect):
00042         result = self.wrapper._split(text)
00043         self.assertEqual(result, expect,
00044                          "\nexpected %r\n"
00045                          "but got  %r" % (expect, result))
00046 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_textwrap.BaseTestCase.check_wrap (   self,
  text,
  width,
  expect,
  kwargs 
) [inherited]

Definition at line 36 of file test_textwrap.py.

00036 
00037     def check_wrap(self, text, width, expect, **kwargs):
00038         result = wrap(text, width, **kwargs)
00039         self.check(result, expect)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 378 of file test_textwrap.py.

00378 
00379     def setUp(self):
00380         self.wrapper = TextWrapper()
00381         self.text = '''\
00382 Did you say "supercalifragilisticexpialidocious?"
00383 How *do* you spell that odd word, anyways?
00384 '''

Here is the caller graph for this function:

def test.test_textwrap.BaseTestCase.show (   self,
  textin 
) [inherited]

Definition at line 20 of file test_textwrap.py.

00020 
00021     def show(self, textin):
00022         if isinstance(textin, list):
00023             result = []
00024             for i in range(len(textin)):
00025                 result.append("  %d: %r" % (i, textin[i]))
00026             result = '\n'.join(result)
00027         elif isinstance(textin, str):
00028             result = "  %s\n" % repr(textin)
00029         return result
00030 

Here is the caller graph for this function:

Definition at line 385 of file test_textwrap.py.

00385 
00386     def test_break_long(self):
00387         # Wrap text with long words and lots of punctuation
00388 
00389         self.check_wrap(self.text, 30,
00390                         ['Did you say "supercalifragilis',
00391                          'ticexpialidocious?" How *do*',
00392                          'you spell that odd word,',
00393                          'anyways?'])
00394         self.check_wrap(self.text, 50,
00395                         ['Did you say "supercalifragilisticexpialidocious?"',
00396                          'How *do* you spell that odd word, anyways?'])
00397 
00398         # SF bug 797650.  Prevent an infinite loop by making sure that at
00399         # least one character gets split off on every pass.
00400         self.check_wrap('-'*10+'hello', 10,
00401                         ['----------',
00402                          '               h',
00403                          '               e',
00404                          '               l',
00405                          '               l',
00406                          '               o'],
00407                         subsequent_indent = ' '*15)
00408 
00409         # bug 1146.  Prevent a long word to be wrongly wrapped when the
00410         # preceding word is exactly one character shorter than the width
00411         self.check_wrap(self.text, 12,
00412                         ['Did you say ',
00413                          '"supercalifr',
00414                          'agilisticexp',
00415                          'ialidocious?',
00416                          '" How *do*',
00417                          'you spell',
00418                          'that odd',
00419                          'word,',
00420                          'anyways?'])

Here is the call graph for this function:

Definition at line 421 of file test_textwrap.py.

00421 
00422     def test_nobreak_long(self):
00423         # Test with break_long_words disabled
00424         self.wrapper.break_long_words = 0
00425         self.wrapper.width = 30
00426         expect = ['Did you say',
00427                   '"supercalifragilisticexpialidocious?"',
00428                   'How *do* you spell that odd',
00429                   'word, anyways?'
00430                   ]
00431         result = self.wrapper.wrap(self.text)
00432         self.check(result, expect)
00433 
00434         # Same thing with kwargs passed to standalone wrap() function.
00435         result = wrap(self.text, width=30, break_long_words=0)
00436         self.check(result, expect)
00437 

Here is the call graph for this function:


Member Data Documentation

Definition at line 380 of file test_textwrap.py.

Definition at line 379 of file test_textwrap.py.


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