I have a stock Pylons app created using paster create -t pylons
with one controller and matched functional test, added using paster controller
, and a SQLAlchemy table and mapped ORM class. The SQLAlchemy stuff is defined in the init_model()
function rather than in module scope (and needs to be there).
Running python setup.py test
raises an exception because nose
is somehow causing init_model()
to be called twice within the same process, so it's trying to create a model that already exists.
I can hackishly fix this by setting and checking a global variable inside init_model()
, but (a) I'd rather not, and (b) third-party libraries such as AuthKit that dynamically define models break the tests as well, and can't be so easily changed.
Is there a way to fix nose
tests for Pylons, or should I write my own test script and just use unittest
, loadapp
, and webtest
directly? Any working examples of this?