Skip to content

Commit 85e1b3a

Browse files
cybergrindfgregg
authored andcommitted
Enable reflection
1 parent ea5c5ee commit 85e1b3a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pytest_flask_sqlalchemy/fixtures.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def _engine(pytestconfig, request, _transaction, mocker):
9393

9494
# Make sure that any attempts to call `connect()` simply return a
9595
# reference to the open connection
96+
9697
engine = mocker.MagicMock(spec=sa.engine.Engine)
9798

9899
engine.connect.return_value = connection
@@ -105,6 +106,12 @@ def _engine(pytestconfig, request, _transaction, mocker):
105106
elif version.parse(sa.__version__) < version.parse('1.4'):
106107
engine._contextual_connect.return_value = connection
107108

109+
# Calls to execution_options should return this mocked engine.
110+
engine.execution_options.return_value = engine
111+
112+
if version.parse(sa.__version__) >= version.parse('1.4'):
113+
sa.inspection._registrars[mocker.MagicMock] = sa.engine.Inspector._engine_insp
114+
108115
# References to `Engine.dialect` should redirect to the Connection (this
109116
# is primarily useful for the `autoload` flag in SQLAlchemy, which references
110117
# the Engine dialect to reflect tables)

0 commit comments

Comments
 (0)