pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
488 stars 236 forks source link

Possible regression: Table 'sessions' is already defined #245

Open Blockguy24 opened 1 month ago

Blockguy24 commented 1 month ago

I was writing some unit tests for my application, which uses the application factory pattern. A new app instance is created for each unittest.TestCase class using setUpClass. The tests work fine, until a new TestCase is encountered and the app gets set up again. This time, an exception occurs when initialising:

sqlalchemy.exc.InvalidRequestError: Table 'sessions' is already defined for this MetaData instance.

This seems to be related to issues #75, #131 and #175, but even though fixes have been applied to resolve those, I'm experiencing issues now on version 0.8.0.

A workaround I found for this is to call db.metadata.clear() in my tearDownClass but I feel like this shouldn't be necessary.