How to organize test cases with PyUnit
Donnal Walter
donnal at donnal.net
Sun Jul 21 22:10:22 EDT 2002
Syver Enstad <syver-en+usenet at online.no> wrote in message news:<u8z45yodt.fsf at online.no>...
> donnal at donnal.net (Donnal Walter) writes:
>
> <snipped>
> >
> > Yes, from the responses here that does appear to be the conventional
> > way of doing things, so I guess I will continue using unittest this
> > way too. I had thought I might replace my batch files with a
> > TestSuite, but I'm really not complaining about the way it works now.
> > Thanks.
>
> Btw, here's some code I put in my __init__.py files to run unittest
> for all modules in a package. Maybe it does some of the things your
> are looking for?
>
>
> moduleNames = map(lambda each: os.path.splitext(each)[0],
> filter(lambda each: each != '__init__.py',
> glob.glob('*.py')))
>
> # this was the testLoader I was talking about, it makes a suite from
> all TestCase derived classes in moduleNames.
>
> suite = unittest.defaultTestLoader.loadTestsFromNames(moduleNames)
>
> runner = unittest.TextTestRunner(verbosity=1)
> runner.run(suite)
Yes, that is what I was looking for. Thanks.
More information about the Python-list
mailing list