views:

31

answers:

1

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 ?

+1  A: 

Hi Alfredo. 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

hpk42
wow, thanks Holger! it is really humbling to get an answer from you! you rock! As to the problem itself, the way nose was gathering app values via setUp method.
alfredodeza
your welcome, alfredo. do you have a URL pointing to the code which implements this setUp functionality and maybe contains some example tests?
hpk42
unfortunately no, it is not an OSS project. However, I have a better insight as to what has been going on. Basically we were implementing a TestSetupCommand class that would bring everything up to speed, so I'm porting that to match py.test requirements.
alfredodeza