-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrite does not work automatically for plugins in develop mode #1934
Comments
Investigating further, I found that in development mode there's the Perhaps we should just try both |
nicoddemus
added a commit
to nicoddemus/pytest
that referenced
this issue
Sep 15, 2016
we might want add a general tool to do ahead of time assert rewriting and mark all plugin as always being rewritten |
(so that we can opt out of always marking them) |
skylarjhdownes
added a commit
to skylarjhdownes/pytest
that referenced
this issue
Sep 27, 2016
This was referenced Sep 29, 2016
This was referenced Feb 20, 2018
This was referenced Mar 5, 2018
joseph-roitman
added a commit
to joseph-roitman/pytest-snapshot
that referenced
this issue
Nov 10, 2023
…tions. See pytest-dev/pytest#1934. Error message: ``` ../../../../home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114 /home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_snapshot self._mark_plugins_for_rewrite(hook) ```
joseph-roitman
added a commit
to joseph-roitman/pytest-snapshot
that referenced
this issue
Nov 10, 2023
Using develop mode may miss issues with the library when installed normally. Additionally, develop mode caused tests to fail on PyPy on Github Actions due to a bug in pytest. See pytest-dev/pytest#1934. Error message: ``` ../../../../home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114 /home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_snapshot self._mark_plugins_for_rewrite(hook) ```
joseph-roitman
added a commit
to joseph-roitman/pytest-snapshot
that referenced
this issue
Nov 10, 2023
Using develop mode may miss issues with the library when installed normally. Additionally, develop mode caused tests to fail on PyPy on Github Actions due to a bug in pytest. See pytest-dev/pytest#1934. Error message: ``` ../../../../home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114 /home/runner/work/pytest-snapshot/pytest-snapshot/.tox/pypy3-pytest6/lib/pypy3.10/site-packages/_pytest/config/__init__.py:1114: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_snapshot self._mark_plugins_for_rewrite(hook) ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pytest-mock
uses pytest's assert introspection to enrich the error message when one of the standardmock.assert*
methods fail. Those asserts are in the plugin module (pytest_mock.py
), and while they are rewritten just fine when installed from a package, they don't get rewritten in development mode (python setup.py develop
).I tracked down the problem to our code which tries to rewrite all modules of installed plugins in
config.py
, function_consider_importhook
:When in development mode,
entrypoint.dist._get_metadata('RECORD')
returns an empty list; digging into that method I noticed it tries to access EGG metadata. Being in development mode, there's no EGG meta-data, so it makes sense.I think the only solution is to move the function which needs assertion rewriting to its own "util" module and call
register_assert_rewrite
before importing it (which is no big deal).Any other ideas on how to fix/workaround it?
cc @flub
The text was updated successfully, but these errors were encountered: