diff --git a/tests/integration/test_app_activity_functions.py b/tests/integration/test_app_activity_functions.py index de080a3..cb4920f 100644 --- a/tests/integration/test_app_activity_functions.py +++ b/tests/integration/test_app_activity_functions.py @@ -35,6 +35,9 @@ class TestFlaskAppActivityFunctions(unittest.TestCase): # Store original database URI self.original_db_uri = app.app.config.get("SQLALCHEMY_DATABASE_URI") + # Store original db engine + self.original_db_engine = db.engine if hasattr(db, 'engine') else None + # Configure test app BEFORE pushing context app.app.config["TESTING"] = True app.app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:" @@ -47,8 +50,11 @@ class TestFlaskAppActivityFunctions(unittest.TestCase): self.app_context = app.app.app_context() self.app_context.push() - # Reinitialize db with the test app to pick up new config - db.init_app(app.app) + # Force db to use the new in-memory database by clearing the engine + # This allows the in-memory database to be created + if hasattr(db, 'engine'): + db.engine.dispose() + db.session.remove() # Re-initialize db with test config to use in-memory database try: