Closed ornj closed 8 years ago
I encountered the same problem. How do you deal with this problem?
Sorry I don't have a good answer for you. To get around it temporarily I had a janky, temporary work around but ultimately I didn't use this in my project.
Hello, I've just added a fix for this issue. I'm now checking for a request context, and if one does not exist, I'm creating a new test request context with the given Flask app. This should allow tests to work regardless of whether the app was passed into the SQLAlchemy
constructor or the init_app
function was called instead. Give it a try, and let me know if this change doesn't fix your problem.
Thanks croach, this change fix my problem.Can you release a new version?I want to use this in my project.
Sorry about that, completely forgot to upload the latest release to PyPI. Anyway, I've made the push now and version 0.3.6 is live, so you should be able to update to the latest version to fix your problem(s).
Thanks, I can pip install flask-fixtures==0.3.6 and test it ok. But maybe you forget add new tag 0.3.6 at github.
Ok, so I pushed the tag for 0.3.6, and I also made a new update and pushed that to this repo and to PyPI. The new change makes the framework even less dependent on the application object. There is a slight change in how you use the framework---you now no longer call init_app
, but instead you specify the app
and db
in class variables. This gives you the ability to test multiple applications by simply subclassing a test class and replacing the app
object. If you'd prefer to use this version instead, just upgrade to v0.3.7.
setup
fails whenSQLAlchemy.init_app()
is used to initialize the application for the database.Example:
Works
Doesn't work
This creates problems when creating the application through a factory function.