From 5a3a7998fb58d91b1dd3ea580528df591e09a04b Mon Sep 17 00:00:00 2001 From: Forest Gregg Date: Mon, 27 Sep 2021 09:16:29 -0400 Subject: [PATCH] don't try subclassing magicmock --- pytest_flask_sqlalchemy/fixtures.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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