Commit f6765781 authored by Greg Ward's avatar Greg Ward

Conform to standards documented in README:

  *  lowercase test*() methods
  * define test_main() and use it instead of unittest.main()
Kill #! line.
Improve some test names and docstrings.
parent 90c0b071
#!/usr/bin/env python
import unittest import unittest
from test import test_support
# import item under test
from textwrap import TextWrapper, wrap, fill from textwrap import TextWrapper, wrap, fill
...@@ -39,7 +37,7 @@ class WrapTestCase(WrapperTestCase): ...@@ -39,7 +37,7 @@ class WrapTestCase(WrapperTestCase):
# Note: any methods that start with "test" are called automatically # Note: any methods that start with "test" are called automatically
# by the unittest framework. # by the unittest framework.
def testSimpleCases(self): def test_simple(self):
'''Simple case: just words, spaces, and a bit of punctuation.''' '''Simple case: just words, spaces, and a bit of punctuation.'''
t = "Hello there, how are you this fine day? I'm glad to hear it!" t = "Hello there, how are you this fine day? I'm glad to hear it!"
...@@ -68,7 +66,7 @@ class WrapTestCase(WrapperTestCase): ...@@ -68,7 +66,7 @@ class WrapTestCase(WrapperTestCase):
self.check(result, expect) self.check(result, expect)
def testWhitespace(self): def test_whitespace(self):
'''Whitespace munging and end-of-sentence detection.''' '''Whitespace munging and end-of-sentence detection.'''
t = """\ t = """\
...@@ -95,7 +93,7 @@ What a mess! ...@@ -95,7 +93,7 @@ What a mess!
self.check(result, '\n'.join(expect)) self.check(result, '\n'.join(expect))
def testWrappingShortToLong(self): def test_wrap_short(self):
'''Wrapping to make short lines longer.''' '''Wrapping to make short lines longer.'''
t = "This is a\nshort paragraph." t = "This is a\nshort paragraph."
...@@ -116,7 +114,7 @@ What a mess! ...@@ -116,7 +114,7 @@ What a mess!
self.check(result, expect) self.check(result, expect)
def testHyphenated(self): def test_hyphenated(self):
'''Test breaking hyphenated words.''' '''Test breaking hyphenated words.'''
t = "this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'ly" t = "this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'ly"
...@@ -143,7 +141,7 @@ What a mess! ...@@ -143,7 +141,7 @@ What a mess!
def test_split(self): def test_split(self):
'''Ensure that the standard _split() method works as advertised '''Ensure that the standard _split() method works as advertised
in the comments (don't you hate it when code and comments diverge?).''' in the comments.'''
t = "Hello there -- you goof-ball, use the -b option!" t = "Hello there -- you goof-ball, use the -b option!"
...@@ -153,8 +151,8 @@ What a mess! ...@@ -153,8 +151,8 @@ What a mess!
"ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"]) "ball,", " ", "use", " ", "the", " ", "-b", " ", "option!"])
def testPoppins(self): def test_funky_punc(self):
'''Please rename this test based on its purpose.''' '''Wrap text with long words and lots of punctuation.'''
t = ''' t = '''
Did you say "supercalifragilisticexpialidocious?" Did you say "supercalifragilisticexpialidocious?"
...@@ -179,7 +177,7 @@ How *do* you spell that odd word, anyways? ...@@ -179,7 +177,7 @@ How *do* you spell that odd word, anyways?
self.check(result, expect) self.check(result, expect)
def testBreakLongWordsOff(self): def test_long_words(self):
'''Test with break_long_words disabled.''' '''Test with break_long_words disabled.'''
t = ''' t = '''
Did you say "supercalifragilisticexpialidocious?" Did you say "supercalifragilisticexpialidocious?"
...@@ -211,7 +209,7 @@ This paragraph will be filled, first without any indentation, ...@@ -211,7 +209,7 @@ This paragraph will be filled, first without any indentation,
and then with some (including a hanging indent).''' and then with some (including a hanging indent).'''
def testFill(self): def test_fill(self):
'''Test the fill() method.''' '''Test the fill() method.'''
expect = '''\ expect = '''\
...@@ -223,7 +221,7 @@ some (including a hanging indent).''' ...@@ -223,7 +221,7 @@ some (including a hanging indent).'''
self.check(result, expect) self.check(result, expect)
def testInitialIndent(self): def test_initial_indent(self):
'''Test initial_indent parameter.''' '''Test initial_indent parameter.'''
expect = [ expect = [
...@@ -243,7 +241,7 @@ with some (including a hanging indent).''' ...@@ -243,7 +241,7 @@ with some (including a hanging indent).'''
self.check(result, expect) self.check(result, expect)
def testSubsequentIndent(self): def test_subsequent_indent(self):
'''Test subsequent_indent parameter.''' '''Test subsequent_indent parameter.'''
expect = '''\ expect = '''\
...@@ -257,5 +255,11 @@ with some (including a hanging indent).''' ...@@ -257,5 +255,11 @@ with some (including a hanging indent).'''
self.check(result, expect) self.check(result, expect)
def test_main():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(WrapTestCase))
suite.addTest(unittest.makeSuite(IndentTestCases))
test_support.run_suite(suite)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() test_main()
\ No newline at end of file
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