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.
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 usingsetUpClass
. The tests work fine, until a newTestCase
is encountered and the app gets set up again. This time, an exception occurs when initialising: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 mytearDownClass
but I feel like this shouldn't be necessary.