Hi Joan,
On Tue, Dec 22, 2009 at 22:48 +0000, Joan Miller wrote:
> Hi everybody!
>
> How to run a setup function at all-tests level? I mean that it been
> run only at starting; and another one at the end --of all tests--.
>
> It's for setup and shutdown the logging.
The current way to do pre/post-alltests setup is to have a
conftest.py file at the root of your project containing the
following hooks:
# complete content of conftest.py
def pytest_sessionstart():
# will be executed before tests are run
def pytest_sessionfinish():
# will be executed after all tests have run
The reason the conftest needs to be at the root level is for
py.test to see it before tests are collected/run.
Putting it into e.g. "testing/conftest.py" is fine as well if you
run the tests with "py.test path/to/testing" usually.
Here is some more info on hooks if you'd like to know more:
http://codespeak.net/py/dist/test/customize.html
HTH,
holger
_______________________________________________
py-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/py-dev