Question

I'm switching our testing environment from Nose to py.test for testing a Turbogears2 web application.

Currently, when Nose runs it gathers information from a testing configuration file (test.ini) that holds all the testing variables the application needs. And it seems to do so in an automatic way (I'm simply running nosetests and everything gets loaded)

The problem relies in the inability for py.test to be pointed at the right INI configuration file so that I can get the app loaded with the variables I need.

Currently, the failing point is pylons.app_globals which is simply non-existent when running py.test (hence everything fails).

I have been through the Turbogears documentation but they only mention Nose/nosetests and nothing else.

Is there a way to be able to lead the application with the testing variables I rely upon with py.test ?

Was it helpful?

Solution

As far as py.test's part is concerned, you can implement something like this:

# content of conftest.py
def pytest_sessionstart():
    # setup resources before any test is executed

def pytest_sessionfinish():
    # teardown resources after the last test has executed

Such a conftest.py file should currently best live at your checkout root directory as py-1.3.4 will only run this hook if it sees it early enough.

I also looked a bit around TurboGears but didn't erasily found the mechanism how/which test.ini is actually loaded. I can update the answer if somebody can provide this information.

HTH. Holger

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top