File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -215,14 +215,15 @@ def test_figureoptions():
215
215
216
216
217
217
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
218
- def test_save_figure_return ():
218
+ def test_save_figure_return (tmp_path ):
219
219
fig , ax = plt .subplots ()
220
220
ax .imshow ([[1 ]])
221
+ expected = tmp_path / "foobar.png"
221
222
prop = "matplotlib.backends.qt_compat.QtWidgets.QFileDialog.getSaveFileName"
222
- with mock .patch (prop , return_value = ("foobar.png" , None )):
223
+ with mock .patch (prop , return_value = (str ( expected ) , None )):
223
224
fname = fig .canvas .manager .toolbar .save_figure ()
224
- os . remove ( "foobar.png" )
225
- assert fname == "foobar.png"
225
+ assert fname == str ( expected )
226
+ assert expected . exists ()
226
227
with mock .patch (prop , return_value = (None , None )):
227
228
fname = fig .canvas .manager .toolbar .save_figure ()
228
229
assert fname is None
You can’t perform that action at this time.
0 commit comments