test_dpi_ratio_change fails on Windows/Qt5Agg · Issue #16123 · matplotlib/matplotlib · GitHub
Skip to content

test_dpi_ratio_change fails on Windows/Qt5Agg #16123

Description

@Kojoley
================================== FAILURES ===================================
____________________________ test_dpi_ratio_change ____________________________
[gw0] win32 -- Python 3.6.7 c:\miniconda36-x64\envs\test-environment\python.exe
    @pytest.mark.backend('Qt5Agg')
    def test_dpi_ratio_change():
        """
        Make sure that if _dpi_ratio changes, the figure dpi changes but the
        widget remains the same physical size.
        """
    
        prop = 'matplotlib.backends.backend_qt5.FigureCanvasQT._dpi_ratio'
    
        with mock.patch(prop, new_callable=mock.PropertyMock) as p:
    
            p.return_value = 3
    
            fig = plt.figure(figsize=(5, 2), dpi=120)
            qt_canvas = fig.canvas
            qt_canvas.show()
    
            from matplotlib.backends.backend_qt5 import qApp
    
            # Make sure the mocking worked
            assert qt_canvas._dpi_ratio == 3
    
            size = qt_canvas.size()
    
            qt_canvas.manager.show()
            qt_canvas.draw()
            qApp.processEvents()
    
            # The DPI and the renderer width/height change
            assert fig.dpi == 360
            assert qt_canvas.renderer.width == 1800
            assert qt_canvas.renderer.height == 720
    
            # The actual widget size and figure physical size don't change
            assert size.width() == 600
            assert size.height() == 240
            assert qt_canvas.get_width_height() == (600, 240)
            assert (fig.get_size_inches() == (5, 2)).all()
    
            p.return_value = 2
    
            assert qt_canvas._dpi_ratio == 2
    
            qt_canvas.draw()
            qApp.processEvents()
            # this second processEvents is required to fully run the draw.
            # On `update` we notice the DPI has changed and trigger a
            # resize event to refresh, the second processEvents is
            # required to process that and fully update the window sizes.
            qApp.processEvents()
    
            # The DPI and the renderer width/height change
            assert fig.dpi == 240
            assert qt_canvas.renderer.width == 1200
>           assert qt_canvas.renderer.height == 480
E           assert 474.0 == 480
E            +  where 474.0 = <matplotlib.backends.backend_agg.RendererAgg object at 0x000000CC215AE2B0>.height

Build log: https://ci.appveyor.com/project/Kojoley/matplotlib/builds/29921850/job/1rdi7tiyqly53n3h

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions