diff --git a/pytest_flask_sqlalchemy/fixtures.py b/pytest_flask_sqlalchemy/fixtures.py index 84439bd..6afb4fd 100644 --- a/pytest_flask_sqlalchemy/fixtures.py +++ b/pytest_flask_sqlalchemy/fixtures.py @@ -93,10 +93,8 @@ def _engine(pytestconfig, request, _transaction, mocker): # Make sure that any attempts to call `connect()` simply return a # reference to the open connection - class EngineMock(mocker.MagicMock): - pass - engine = EngineMock(spec=sa.engine.Engine) + engine = mocker.MagicMock(spec=sa.engine.Engine) engine.connect.return_value = connection @@ -109,10 +107,10 @@ class EngineMock(mocker.MagicMock): engine._contextual_connect.return_value = connection # Calls to execution_options should return this mocked engine. - # engine.execution_options.return_value = engine + engine.execution_options.return_value = engine if version.parse(sa.__version__) >= version.parse('1.4'): - sa.inspection._registrars[EngineMock] = sa.engine.Inspector._engine_insp + sa.inspection._registrars[mocker.MagicMock] = sa.engine.Inspector._engine_insp # References to `Engine.dialect` should redirect to the Connection (this # is primarily useful for the `autoload` flag in SQLAlchemy, which references