r46599 - python/trunk/Lib/test/test_exceptions.py
Author: neal.norwitz Date: Fri Jun 2 06:45:53 2006 New Revision: 46599 Modified: python/trunk/Lib/test/test_exceptions.py Log: Convert docstrings to comments so regrtest -v prints method names Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Fri Jun 2 06:45:53 2006 @@ -112,8 +112,8 @@ except Exception, e: pass def testSyntaxErrorMessage(self): - """make sure the right exception message is raised for each of - these code fragments""" + # make sure the right exception message is raised for each of + # these code fragments def ckmsg(src, msg): try: @@ -143,8 +143,8 @@ ckmsg("continue\n", "'continue' not properly in loop") def testSettingException(self): - """test that setting an exception at the C level works even if the - exception object can't be constructed.""" + # test that setting an exception at the C level works even if the + # exception object can't be constructed. class BadException: def __init__(self_): @@ -181,7 +181,7 @@ test_capi2() def testAttributes(self): - """test that exception attributes are happy.""" + # test that exception attributes are happy try: str(u'Hello \u00E1') except Exception, e: sampleUnicodeEncodeError = e @@ -280,8 +280,8 @@ (repr(e), checkArgName)) def testKeywordArgs(self): - """test that builtin exception don't take keyword args, - but user-defined subclasses can if they want""" + # test that builtin exception don't take keyword args, + # but user-defined subclasses can if they want self.assertRaises(TypeError, BaseException, a=1) class DerivedException(BaseException):
On 6/2/06, neal.norwitz <python-checkins@python.org> wrote:
Author: neal.norwitz Date: Fri Jun 2 06:45:53 2006 New Revision: 46599
Modified: python/trunk/Lib/test/test_exceptions.py Log: Convert docstrings to comments so regrtest -v prints method names
Wouldn't it make more sense to modify regrtest -v to print method names (possibly in addition to the docstring)? -jJ
Author: neal.norwitz Date: Fri Jun 2 06:45:53 2006 New Revision: 46599
Modified: python/trunk/Lib/test/test_exceptions.py Log: Convert docstrings to comments so regrtest -v prints method names
[Jim Jewett]
Wouldn't it make more sense to modify regrtest -v to print method names (possibly in addition to the docstring)?
It has nothing to do with regrtest -- it's an (undocumented?) (mis)feature of unittest's TextTestRunner that it displays the docstring instead of a test method's name and test class whenever a test method has a non-empty docstring, and unittest (not regrtest) is what produces the output here. For example, try this minimal unittest: """ import unittest class Whatever(unittest.TestCase): def testequal(self): self.assertEqual(2, 2) if __name__ == '__main__': unittest.main() """ Then running "python THATFILE.py -v" displays """ testequal (__main__.Whatever) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.000s OK """ Add a non-empty docstring to the method: """ def testequal(self): """I think I'm being helpful.""" self.assertEqual(2, 2) """ and it displays """ I think I'm being helpful. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.000s OK """ instead. For that reason, most people avoid docstrings in unittest test methods like plague. regrtest has no control of its own over unittest's output.
On 6/2/06, Tim Peters <tim.peters@gmail.com> wrote:
instead. For that reason, most people avoid docstrings in unittest test methods like plague. regrtest has no control of its own over unittest's output.
Perhaps it's time to change this unittest behavior, or at least provide a flag to disable it? -- --Guido van Rossum (home page: http://www.python.org/~guido/)
On 6/2/06, Guido van Rossum <guido@python.org> wrote:
On 6/2/06, Tim Peters <tim.peters@gmail.com> wrote:
instead. For that reason, most people avoid docstrings in unittest test methods like plague. regrtest has no control of its own over unittest's output.
Perhaps it's time to change this unittest behavior, or at least provide a flag to disable it?
Sounds good to me. Should it ignore the docstring entirely, or just append (the first line of) it to the method name? In other words, given def testStupidData(...): """Ensure that certain nonsense input combinations don't cause a crash. Resolves bug 843, crash on negative height""" Should the output be testStupidData or testStupidData - Ensure that certain nonsense input combinations don't cause a crash. Or should I let this be controlled by verbosity level? (verbosity 2 adding the string) -jJ
participants (4)
-
Guido van Rossum -
Jim Jewett -
neal.norwitz -
Tim Peters