Skip to content

[Bug]: Qt test_ipython fails on older ipython #28202

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

Closed
QuLogic opened this issue May 9, 2024 · 2 comments · Fixed by #28205
Closed

[Bug]: Qt test_ipython fails on older ipython #28202

QuLogic opened this issue May 9, 2024 · 2 comments · Fixed by #28205
Milestone

Comments

@QuLogic
Copy link
Member

QuLogic commented May 9, 2024

Bug summary

I have an older conda environment with ipython 8.8.0, and this test seems to be failing. Also when building on Fedora Rawhide with ipython 8.24.0, I see the failure as well. I'm not sure why this passes (but fails with my environments) with the minimum versions in CI.

cc @ianthomas23

Code for reproduction

$ pytest lib/matplotlib/tests/test_backend_qt.py::test_ipython

Actual outcome

________ test_ipython ________

    def test_ipython():
        from matplotlib.testing import ipython_in_subprocess
>       ipython_in_subprocess("qt", "QtAgg", "qtagg")

lib/matplotlib/tests/test_backend_qt.py:381: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

requested_backend_or_gui_framework = 'qt', expected_backend_old_ipython = 'QtAgg', expected_backend_new_ipython = 'qtagg'

    def ipython_in_subprocess(
        requested_backend_or_gui_framework,
        expected_backend_old_ipython,  # IPython < 8.24
        expected_backend_new_ipython,  # IPython >= 8.24
    ):
        import pytest
        IPython = pytest.importorskip("IPython")
    
        if sys.platform == "win32":
            pytest.skip("Cannot change backend running IPython in subprocess on Windows")
    
        if (IPython.version_info[:3] == (8, 24, 0) and
                requested_backend_or_gui_framework == "osx"):
            pytest.skip("Bug using macosx backend in IPython 8.24.0 fixed in 8.24.1")
    
        if IPython.version_info[:2] >= (8, 24):
            expected_backend = expected_backend_new_ipython
        else:
            # This code can be removed when Python 3.12, the latest version supported by
            # IPython < 8.24, reaches end-of-life in late 2028.
            expected_backend = expected_backend_old_ipython
    
        code = ("import matplotlib as mpl, matplotlib.pyplot as plt;"
                "fig, ax=plt.subplots(); ax.plot([1, 3, 2]); mpl.get_backend()")
        proc = subprocess_run_for_testing(
            [
                "ipython",
                "--no-simple-prompt",
                f"--matplotlib={requested_backend_or_gui_framework}",
                "-c", code,
            ],
            check=True,
            capture_output=True,
        )
    
>       assert proc.stdout.strip() == f"Out[1]: '{expected_backend}'"
E       AssertionError

lib/matplotlib/testing/__init__.py:217: AssertionError

Expected outcome

The test passes.

Additional information

If I print out the proc.stdout, then I get Out[1]: 'Qt5Agg'; the test appears to be looking for 'qtagg', instead?

Operating system

Fedora 39/Rawhide

Matplotlib Version

main (3ee509d)

Installation

git checkout

@QuLogic
Copy link
Member Author

QuLogic commented May 10, 2024

In said conda environment, I have PyQt5 and PyQt6 installed, but not PySide2 or PySide6.

@QuLogic
Copy link
Member Author

QuLogic commented May 10, 2024

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 a pull request may close this issue.

1 participant