[py-dev] py.test : setup / teardown at the directory level
Philippe Fremy
phil at freehackers.org
Tue Apr 28 17:09:02 CEST 2009
holger krekel wrote:
> Hi Philippe,
Hi Holger,
>
> On Tue, Apr 28, 2009 at 13:37 +0200, Philippe Fremy wrote:
>> Hi,
>>
>> I was wondering if there is a possibility to have or emulate
>> setup/teardown method for an entire directory of tests ?
>>
>> I have an expensive setup/teardown method, which I share through about
>> 10 modules, each with about 20 tests. I would save time if I could do
>> the setup/teardown just for that directory.
>
> do you have a setup_module()/teardown_module() pair that
> you import into all your tests?
Exactly.
> Do you essentially want to setup the test resource
> only once per test-run?
Once per session would be actually sufficient for this specific case
today, but the need is once per test directory.
To be a bit more explicit, in my current software development, I have
both unit tests for functionality in App1 that I develop myself, and
functional tests for a wrapper around App2, which is an external
application :
base
+ app1
+ tests
+ many unit tests
+ app2_wrapper
+ external_app2
+ tests
+ many functional tests for the app2 wrapper, requiring to setup
a resource for app2 to run.
I launch py.test from the base directory.
I have an expensive setup/teardown for the functional tests of the app2
wrapper, which I would like to share at the app2_wrapper/tests directory
level.
Ideally, if I run only tests from app1, I don't run that expensive
setup/teardown.
cheers,
Philippe
More information about the Pytest-dev
mailing list