Skip to content

[Bug]: test_save_figure_return seems flaky #30493

@QuLogic

Description

@QuLogic

Bug summary

When building on Fedora builders, I often get this failure, though it is not consistent and I've never had it happen locally.

Code for reproduction

pytest tests/test_backend_qt.py -k test_save_figure_return

Actual outcome

___________________________ test_save_figure_return ____________________________
[gw2] linux -- Python 3.14.0 /usr/bin/python3

    @pytest.mark.backend('QtAgg', skip_on_importerror=True)
    def test_save_figure_return():
        fig, ax = plt.subplots()
        ax.imshow([[1]])
        prop = "matplotlib.backends.qt_compat.QtWidgets.QFileDialog.getSaveFileName"
        with mock.patch(prop, return_value=("foobar.png", None)):
            fname = fig.canvas.manager.toolbar.save_figure()
>           os.remove("foobar.png")
E           FileNotFoundError: [Errno 2] No such file or directory: 'foobar.png'

../BUILDROOT/usr/lib64/python3.14/site-packages/matplotlib/tests/test_backend_qt.py:228: FileNotFoundError

Expected outcome

Tests always pass.

Additional information

No response

Operating system

No response

Matplotlib Version

3.10.6

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

from source (.tar.gz)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions