FAQ
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?

The dir has to be created just once, before any tests run, and then
multiple packages and multiple modules in them are imported and run.

Thanks! -ak

Search Discussions

  • Ben Finney at Oct 26, 2010 at 9:12 pm

    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
  • Steve Holden at Oct 26, 2010 at 9:43 pm

    On 10/26/2010 2:46 PM, AK wrote:
    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?

    The dir has to be created just once, before any tests run, and then
    multiple packages and multiple modules in them are imported and run.
    In which case a class variable would seem to be the appropriate mechanism.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    PyCon 2011 Atlanta March 9-17 http://us.pycon.org/
    See Python Video! http://python.mirocommunity.org/
    Holden Web LLC http://www.holdenweb.com/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedOct 26, '10 at 6:46p
activeOct 26, '10 at 9:43p
posts3
users3
websitepython.org

3 users in discussion

Steve Holden: 1 post Ben Finney: 1 post AK: 1 post

People

Translate

site design / logo © 2022 Grokbase