This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect description of unittest.TestCase.run
Type: Stage: resolved
Components: Documentation Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: ezio.melotti, georg.brandl, zhouer
Priority: normal Keywords:

Created on 2009-06-30 19:43 by zhouer, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg89948 - (view) Author: En-Ran Zhou (zhouer) Date: 2009-06-30 19:43
In Python 2.6 Document, Library reference 26.3 unittest
(http://docs.python.org/library/unittest.html#unittest.TestCase.run)
The description of TestCase.run method says that ``If result is omitted
or None, a temporary result object is created (by calling the
defaultTestCase() method) and used'', but I think it should be
defaultTestResult() instead of defaultTestCase().
msg89950 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-06-30 21:54
>>> class MyTest(TestCase):
...   def runTest(self): pass
...   def defaultTestCase(self):
...     print('defaultTestCase called')
...
>>> test = MyTest()
>>> test.run()
>>> class MyTest(TestCase):
...   def runTest(self): pass
...   def defaultTestResult(self):
...     print('defaultTestResult called')
...
>>> test = MyTest()
>>> test.run()
defaultTestResult called
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programmi\Python31\lib\unittest.py", line 461, in run
    result.startTest(self)
AttributeError: 'NoneType' object has no attribute 'startTest'

I think you are right, here only "defaultTestResult called" is printed
(just before the traceback). Also there's no doc about
defaultTestCase(). The doc can also be clearer about 'result object',
possibly replacing that part with 'a temporary TestResult instance'.
msg89955 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-06-30 22:59
Fixed in r73712.
I left "result object" because the object can also be a subclass of
TestResult. I also changed the last part to clarify that the result
object is never returned to the caller, even when it's passed to run().

Thanks!
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50640
2009-06-30 22:59:49ezio.melottisetstatus: open -> closed
resolution: fixed
messages: + msg89955

stage: resolved
2009-06-30 21:54:53ezio.melottisetpriority: normal

nosy: + ezio.melotti
versions: + Python 3.0, Python 3.1
messages: + msg89950

assignee: georg.brandl -> ezio.melotti
2009-06-30 19:43:07zhouercreate