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: unittest documentation is incomplete
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: collinwinter Nosy List: ajaksu2, collinwinter, georg.brandl, vstinner
Priority: normal Keywords:

Created on 2007-03-16 10:17 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg31540 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2007-03-16 10:17
When I tried to write a test suite using many test cases, I read the documentation (docs.python.org) but it does work because I was unable to run my test suite. Using Google I realised that documentation is incomplete! In Python binding of gstreamer, I found a "TextTestRunner"!

So, would it be possible to update the doc?
msg31541 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-16 13:02
Could you please state what exactly is missing from the documentation, in your opinion?
msg31542 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2007-03-19 02:00
"Could you please state what exactly is missing from the documentation, in your opinion?"

Well, when I ready Python documentation I expect to have the full list of "builtin" modules, functions and classes. But if you check unittest module, documentation only list TestCase, TestSuite, TestResult and TestLoader. Whereas dir(unittest) gives TestCase, TestLoader, *TestProgram*, TestResult, TestSuite, *TextTestRunner*.

So information about TestProgram and TextTestRunner is missing.

I also expect a small example showing how to use a test runner and a test suite.

I'm using:
------------------------------ 8< -----------------------

from unittest import TestSuite, TestLoader, TextTestRunner
from sys import exit

def loadTests(loader):
    """Generator listing all test cases"""
    ...

def main():
    loader = TestLoader()

    suite = TestSuite()
    for test in loadTests(loader.loadTestsFromTestCase):
        suite.addTests(test)

    runner = TextTestRunner(descriptions=2, verbosity=2)
    result = runner.run(suite)
    if result.failures or result.errors:
        exit(1)

------------------------------ 8< -----------------------
msg31543 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-28 22:05
I don't see the need to document TestProgram or TextTestRunner; the former is an implementation detail of the module (and a messy detail, to boot), not meant to be used in third-party code; the only time you'd come across the latter is when implementing custom test runners, in which case you're to the point of reading the module's source anyway.

As for an example of how to use test runners and test suites, why? "unittest.main()" means most users never need to know about these things. Totally comprehensive documentation is an easy thing to get lost in.
msg84120 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-03-24 23:05
> I don't see the need to document TestProgram or TextTestRunner

Ok. And I don't want (have time/motivation) to document them. So I 
prefer to close this issue.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44730
2009-03-24 23:05:08vstinnersetstatus: open -> closed
resolution: not a bug
messages: + msg84120
2008-09-13 00:06:45ajaksu2setnosy: + ajaksu2
2007-03-16 10:17:59vstinnercreate