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 @@ -219,14 +219,15 @@ def test_figureoptions():
219
219
220
220
221
221
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
222
- def test_save_figure_return ():
222
+ def test_save_figure_return (tmp_path ):
223
223
fig , ax = plt .subplots ()
224
224
ax .imshow ([[1 ]])
225
+ expected = tmp_path / "foobar.png"
225
226
prop = "matplotlib.backends.qt_compat.QtWidgets.QFileDialog.getSaveFileName"
226
- with mock .patch (prop , return_value = ("foobar.png" , None )):
227
+ with mock .patch (prop , return_value = (str ( expected ) , None )):
227
228
fname = fig .canvas .manager .toolbar .save_figure ()
228
- os . remove ( "foobar.png" )
229
- assert fname == "foobar.png"
229
+ assert fname == str ( expected )
230
+ assert expected . exists ()
230
231
with mock .patch (prop , return_value = (None , None )):
231
232
fname = fig .canvas .manager .toolbar .save_figure ()
232
233
assert fname is None
You can’t perform that action at this time.
0 commit comments