Skip to content

Broken imports in matplotlib tests in 6.2.0 #5253

Description

@mgorny

Since the 6.2.0 release, pytest fails to collect matplot tests:

========================================================= test session starts =========================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0
rootdir: /tmp/plotly.pyconfigfile: pyproject.tomlplugins: anyio-4.9.0, typeguard-4.4.4
collected 3383 items / 1 error =============================================================== ERRORS ================================================================
________________________________ ERROR collecting plotly/matplotlylib/mplexporter/tests/test_utils.py _________________________________
ImportError while importing test module '/tmp/plotly.py/plotly/matplotlylib/mplexporter/tests/test_utils.py'.
Hint: make sure your test modules/packages have valid Python names.Traceback:
/usr/lib/python3.13/importlib/__init__.py:88: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
plotly/matplotlylib/mplexporter/tests/test_utils.py:2: in <module>
from . import plt
E ImportError: cannot import name 'plt' from 'plotly.matplotlylib.mplexporter.tests' (/tmp/plotly.py/plotly/matplotlylib/mplexporter/tests/__init__.py)
========================================================== warnings summary ===========================================================
plotly/conftest.py:4
/tmp/plotly.py/plotly/conftest.py:4: PytestRemovedIn9Warning:
The (path: py.path.local) argument is deprecated, please use (collection_path: pathlib.Path)
see https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path
tests/test_io/test_to_from_plotly_json.py:112
/tmp/plotly.py/tests/test_io/test_to_from_plotly_json.py:112: UserWarning:
no explicit representation of timezones available for np.datetime64
.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:120
/tmp/plotly.py/.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:120: SyntaxWarning:
invalid escape sequence '\('
.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:375
/tmp/plotly.py/.venv/lib/python3.13/site-packages/pdfrw/objects/pdfstring.py:375: SyntaxWarning:
invalid escape sequence '\['
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info =======================================================
ERROR plotly/matplotlylib/mplexporter/tests/test_utils.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================== 4 warnings, 1 error in 8.27s =====================================================

This seems to be caused by eb95abc that removed the plt import from plotly/matplotlylib/mplexporter/tests/__init__.py.

To reproduce:

pip install -e .[dev_optional] matplotlib
pytest

CC @gvwilson

Activity

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

Metadata

Metadata

Assignees

Labels

P1needed for current cyclebugsomething brokenregressionthis used to work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions