Unittest: how to pass information to TestCase classes?

Ben Finney ben+python at benfinney.id.au
Tue Oct 26 23:12:16 CEST 2010

AK <andrei.avk at gmail.com> writes:

> Hi, I have a question about unittest: let's say I create a temp dir
> for my tests, then use loadTestsFromNames() to load my tests from
> packages and modules they're in, then use TextTestRunner.run() to run
> the tests, how can I pass information to TestCase instances, e.g. the
> location of the temp dir I created?

Have it available from outside the TestCase child classes. Either as a
module-level global, or imported from some other module.

 \       Moriarty: “Forty thousand million billion dollars? That money |
  `\            must be worth a fortune!” —The Goon Show, _The Sale of |
_o__)                                                       Manhattan_ |
Ben Finney

More information about the Python-list mailing list