@pytest.mark.backend('Qt5Agg')
def test_dpi_ratio_change():
    '\n    Make sure that if _dpi_ratio changes, the figure dpi changes but the\n    widget remains the same physical size.\n    '
    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
        assert (qt_canvas._dpi_ratio == 3)
        size = qt_canvas.size()
        qt_canvas.manager.show()
        qt_canvas.draw()
        qApp.processEvents()
        assert (fig.dpi == 360)
        assert (qt_canvas.renderer.width == 1800)
        assert (qt_canvas.renderer.height == 720)
        assert (size.width() == 600)
        assert (size.height() == 240)
        p.return_value = 2
        assert (qt_canvas._dpi_ratio == 2)
        qt_canvas.draw()
        qApp.processEvents()
        qApp.processEvents()
        assert (size.width() == 600)
        assert (size.height() == 240)
Make sure that if _dpi_ratio changes, the figure dpi changes but the
widget remains the same physical size.
@pytest.mark.backend('Qt5Agg')
def test_dpi_ratio_change():
    '\n    Make sure that if _dpi_ratio changes, the figure dpi changes but the\n    widget remains the same physical size.\n    '
    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
        assert (qt_canvas._dpi_ratio == 3)
        size = qt_canvas.size()
        qt_canvas.manager.show()
        qt_canvas.draw()
        qApp.processEvents()
        assert (fig.dpi == 360)
        assert (qt_canvas.renderer.width == 1800)
        assert (qt_canvas.renderer.height == 720)
        assert (size.width() == 600)
        assert (size.height() == 240)
        p.return_value = 2
        assert (qt_canvas._dpi_ratio == 2)
        qt_canvas.draw()
        qApp.processEvents()
        qApp.processEvents()
        assert (size.width() == 600)
        assert (size.height() == 240)