Skip to content

Conversation

@befeleme
Copy link

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:

___________________ 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 collectingtests/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.

befeleme and others added 2 commits January 19, 2026 12:09
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`.
@chrisjsewell
Copy link
Member

fixed in #1090 cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants