Pylons: Testing Configuration
June 7, 2009 § Leave a comment
It’s nice that Pylons include nosetest and TestUnit as part of its testing framework.
Unfortunately, using those for unit testing inside Pylons is not trivial, not obvious, and inconvenient.
- I can only run nosetests on top-level directory because config is expecting ‘test.ini’ file. That’s inconvenient.
- It is not obvious how build sqlalchemy’s engine inside tests/__init__.py. Ideally, I can build the engine based on test.ini configurations.
The __init__ file solves various problems:
- I can run nosetests anywhere inside project’s directory tree.
- With simple convention, __init__ will look for test.ini file on top-level directory.
- SqlAlchemy engine is built using configuration set in test.ini
I hope this snippet can help readers in getting up to speed in Pylons even quicker.