| 81 | |
| 82 | @pytest.mark.backend('pdf') |
| 83 | def test_non_gui_warning(monkeypatch): |
| 84 | plt.subplots() |
| 85 | |
| 86 | monkeypatch.setenv("DISPLAY", ":999") |
| 87 | |
| 88 | with pytest.warns(UserWarning) as rec: |
| 89 | plt.show() |
| 90 | assert len(rec) == 1 |
| 91 | assert ('FigureCanvasPdf is non-interactive, and thus cannot be shown' |
| 92 | in str(rec[0].message)) |
| 93 | |
| 94 | with pytest.warns(UserWarning) as rec: |
| 95 | plt.gcf().show() |
| 96 | assert len(rec) == 1 |
| 97 | assert ('FigureCanvasPdf is non-interactive, and thus cannot be shown' |
| 98 | in str(rec[0].message)) |
| 99 | |
| 100 | |
| 101 | def test_grab_clear(): |