unittest and automatically firing off tests

John J. Lee jjl at pobox.com
Sun Jun 22 00:33:08 CEST 2003

Tom Plunket <tomas at fancy.org> writes:

> John J. Lee wrote:
> > > 1) Why in the name of all that is holy does unittest.main() throw
> > >    regardless of tests passing?
> > 
> > I guess you mean 'raise', not 'throw'.  Does it?  I don't think it
> > does.
> Yes, I mean raise, and yes, it does.  Have you tried executing it
> before trying to give advice?

No.  :-/  Sorry.

> > PyUnit works in terms of TestSuites.  Read the docs.
> Yes I know.  Unfortunately, those of us who have read the docs
> and read the code understand that unittest.main() takes a module
> name or a module, and not a TestSuite.

Calm, calm.

I wasn't talking about unittest.main.  My quick look at the source at
the time I wrote that script I pointed you to made it clear that
unittest.main was implemented in terms of stuff that was designed to
be easily re-used, so I assumed you must not have looked at the source
(and the docstrings therein).  Hmm, did I mention the source?  I meant

> > For one kludge to run tests from several test scripts, see test.py in
> > 
> > http://wwwsearch.sourceforge.net/ClientCookie/src/ClientCookie-0.4.2a.tar.gz
> > 
> > Doubtless I could have done it better if I'd used all of PyUnit's
> > features.
> Yeah, that's a pretty miserable hack.

:-) It works, with minimal effort.  A good pragmatic solution if name
clashes are not likely and you have a relatively small amount of code.

> From discussions
> elsewhere, sucking in all of the tests in that way is pretty much
> not nice.  ;)

(Not sure which discussions you mean there.)

> > If that's not enough, I know it's hard, but you'll just have to admit
> > that you need to read the docs ;-)
> Thanks, maybe you should yourself before offering this advice.  I
> have found that the docs that are available are seriously
> incomplete so I ended up actually reading the code.

Hmm.  It's a few years since I read them, I admit, but looking at the
docstrings now (I should have mentioned the docstrings, of course),
they don't look bad, for a module of only 750-odd lines (including
the docstrings!).


More information about the Python-list mailing list