Unify the conftest imports and set the import mode to discover them#1089
Closed
befeleme wants to merge 2 commits intoexecutablebooks:masterfrom
Closed
Unify the conftest imports and set the import mode to discover them#1089befeleme wants to merge 2 commits intoexecutablebooks:masterfrom
befeleme wants to merge 2 commits intoexecutablebooks:masterfrom
Conversation
The tests have two ways of importing from conftest: directly and via
tests.conftest.
When running the tests directly via `pytest`, the output is:
___________________ ERROR collecting
tests/test_html/test_html_to_nodes.py ____________________
ImportError while importing test module
'/builddir/build/BUILD/python-myst-parser-5.0.0-build/MyST-Parser-5.0.0/tests/test_html/test_html_to_nodes.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.14/importlib/__init__.py:88: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_html/test_html_to_nodes.py:9: in <module>
from tests.conftest import normalize_doctree_xml
E ModuleNotFoundError: No module named 'tests'
When running with `pytest --import-mode=importlib`, other tests raise
ImportError:
_______________ ERROR collecting
tests/test_renderers/test_fixtures_docutils.py _______________
ImportError while importing test module
'/builddir/build/BUILD/python-myst-parser-5.0.0-build/MyST-Parser-5.0.0/tests/test_renderers/test_fixtures_docutils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_renderers/test_fixtures_docutils.py:14: in <module>
from conftest import normalize_doctree_xml
E ModuleNotFoundError: No module named 'conftest'
It's not possible to fix everything so that the direct imports from
conftest are applied, because there are two conftest.py files present in
the repository at different locations.
The fix applied imports from `tests.conftest` everywhere, which also
requires a change in the import mode, added to pyproject.toml.
The end result works consistently when invoked just with `pytest`.
for more information, see https://pre-commit.ci
Member
|
fixed in #1090 cheers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tests have two ways of importing from conftest: directly and via tests.conftest.
In Fedora I've encountered issues with running tests of 5.0.0 during the build.
When running the tests directly via
pytest, the output is:When running with
pytest --import-mode=importlib, other tests raise ImportError:It's not possible to fix everything so that the direct imports from conftest are applied, because there are two conftest.py files present in the repository at different locations.
The fix applied imports from
tests.conftesteverywhere, which also requires a change in the import mode, added to pyproject.toml. The end result works consistently when invoked just withpytest.