-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Plugin tests break on python 3.10 because of importlib and pytest assertion rewriting #1854
Comments
Thanks @martenlienen. Hydra does not officially support python 3.10 yet. I've created #1856 to track this. |
Maybe |
Hydra is registering a pytest plugin in setup.py ( |
From the issue description, it sounds like a regression in pytest. Is there an issue there? |
There is pytest-dev/pytest#2506 which reports a problem with
there might not be an easy fix. |
It's not just import hydra
from _pytest.assertion.rewrite import AssertionRewritingHook
def test_rewriting():
assert isinstance(hydra.__loader__, AssertionRewritingHook)
# This test passes if you run it with pytest.
# It fails if you run it manually by e.g. importing `test_rewriting` and calling it from a REPL. If you modify our So what changed between python3.9 and python3.10? Hydra's The folks at As an alternative to waiting for the next pytest version, we could try to restructure our code so that other parts of hydra (besides the |
Thanks again @martenlienen |
Per offline discussion with Hydra team, we'll wait until the next version of pytest is released incorporating PR pytest-dev/pytest#9173, which should resolve this issue. |
any new news about this? |
Hydra now uses pytest version 7 in our CI, which means that Hydra+python3.10+pytest7 should all work together. We plan to support Python3.10 in the upcoming Hydra1.2 release (which is scheduled for mid-April). |
🐛 Bug
Description
pytest's assertion rewriting replaces the loader in a module's
__spec__
for modules with rewriting enabled. This loader does not implementget_resource_reader
whichimportlib.resources.is_resource
uses internally. For some reason,hydra.test_utils
gets registered for assertion rewriting which means thathydra.test_utils.configs
is not recognized as a resource and cannot be loaded as a config source by hydra.The tests can be made to pass by disabling assertion rewriting with
pytest --assert=plain
or putting it inpyproject.toml
.To reproduce
This can reproduced in the example sweeper plugin.
** Stack trace/error message **
Expected Behavior
The tests should succeed.
System information
The text was updated successfully, but these errors were encountered: