Factor LongWordTestCase out of WrapTestCase, and rename its methods

(tests) from test_funky_punc() to test_break_long() and
test_long_words() to test_nobreak_long().
This commit is contained in:
Greg Ward 2002-08-22 19:02:37 +00:00
parent 13c53c64db
commit fd030e46a7
1 changed files with 14 additions and 13 deletions

View File

@ -124,29 +124,29 @@ def test_split(self):
"ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"]) "ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"])
def test_funky_punc(self): class LongWordTestCase (BaseTestCase):
'''Wrap text with long words and lots of punctuation.''' def setUp(self):
self.wrapper = TextWrapper()
text = ''' self.text = '''
Did you say "supercalifragilisticexpialidocious?" Did you say "supercalifragilisticexpialidocious?"
How *do* you spell that odd word, anyways? How *do* you spell that odd word, anyways?
''' '''
self.check_wrap(text, 30,
def test_break_long(self):
'''Wrap text with long words and lots of punctuation.'''
self.check_wrap(self.text, 30,
['Did you say "supercalifragilis', ['Did you say "supercalifragilis',
'ticexpialidocious?" How *do*', 'ticexpialidocious?" How *do*',
'you spell that odd word,', 'you spell that odd word,',
'anyways?']) 'anyways?'])
self.check_wrap(text, 50, self.check_wrap(self.text, 50,
['Did you say "supercalifragilisticexpialidocious?"', ['Did you say "supercalifragilisticexpialidocious?"',
'How *do* you spell that odd word, anyways?']) 'How *do* you spell that odd word, anyways?'])
def test_long_words(self): def test_nobreak_long(self):
'''Test with break_long_words disabled.''' '''Test with break_long_words disabled.'''
text = '''
Did you say "supercalifragilisticexpialidocious?"
How *do* you spell that odd word, anyways?
'''
self.wrapper.break_long_words = 0 self.wrapper.break_long_words = 0
self.wrapper.width = 30 self.wrapper.width = 30
expect = ['Did you say', expect = ['Did you say',
@ -154,11 +154,11 @@ def test_long_words(self):
'How *do* you spell that odd', 'How *do* you spell that odd',
'word, anyways?' 'word, anyways?'
] ]
result = self.wrapper.wrap(text) result = self.wrapper.wrap(self.text)
self.check(result, expect) self.check(result, expect)
# Same thing with kwargs passed to standalone wrap() function. # Same thing with kwargs passed to standalone wrap() function.
result = wrap(text, width=30, break_long_words=0) result = wrap(self.text, width=30, break_long_words=0)
self.check(result, expect) self.check(result, expect)
@ -221,6 +221,7 @@ def test_subsequent_indent(self):
def test_main(): def test_main():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(WrapTestCase)) suite.addTest(unittest.makeSuite(WrapTestCase))
suite.addTest(unittest.makeSuite(LongWordTestCase))
suite.addTest(unittest.makeSuite(IndentTestCases)) suite.addTest(unittest.makeSuite(IndentTestCases))
test_support.run_suite(suite) test_support.run_suite(suite)