Closed nebolax closed 3 months ago
@nebolax for a short term fix, I think you need what is updated in pr #170 👍🏽
You could update a fork for your project or use flask-session2 until this gets fixed here.
Thanks for the suggestion @christopherpickering ! Unfortunately this does not help since the error happens at the point of initializing the session db model (class Session(self.db.Model):
)
I was able to workaround this by executing db.metadata.clear()
or db.metadata._remove_table('sessions', your_schema_name)
before every Session
initialization in my tests.
@christopherpickering will it make sense to open a PR to fix this? In #170 this problem still exists
Here is the pr #176. Looking forward for a review! @christopherpickering
Looks good to me. I will let someone else review as well.
Now fixed.
I am trying to run tests on my app that uses flask_session and I use sqlalchemy to store sessions data (it gets stored in
sessions
table).If I run tests one-by-one, everything is fine. But if I run multiple tests, then starting at the second test and on I am getting error
sqlalchemy.exc.InvalidRequestError: Table 'sessions' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
. And I am getting it even if I reset all tables in the db before / after every test.What am I doing wrong and how can I solve this?