[ python-Bugs-1681984 ] unittest documentation is incomplete

SourceForge.net noreply at sourceforge.net
Thu Mar 29 00:05:40 CEST 2007


Bugs item #1681984, was opened at 2007-03-16 06:17
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681984&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: STINNER Victor (haypo)
Assigned to: Collin Winter (collinwinter)
Summary: unittest documentation is incomplete

Initial Comment:
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?

----------------------------------------------------------------------

>Comment By: Collin Winter (collinwinter)
Date: 2007-03-28 18:05

Message:
Logged In: YES 
user_id=1344176
Originator: NO

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.

----------------------------------------------------------------------

Comment By: STINNER Victor (haypo)
Date: 2007-03-18 22:00

Message:
Logged In: YES 
user_id=365388
Originator: YES

"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< -----------------------

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-16 09:02

Message:
Logged In: YES 
user_id=849994
Originator: NO

Could you please state what exactly is missing from the documentation, in
your opinion?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1681984&group_id=5470


More information about the Python-bugs-list mailing list