Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8a3028

Browse files
committed
add tests to webagg and tk backend
1 parent c58a062 commit f8a3028

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/matplotlib/tests/test_backend_tk.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ class Toolbar(NavigationToolbar2Tk):
196196
print("success")
197197

198198

199+
@_isolated_tk_test(success_count=1)
200+
def test_save_figure_return():
201+
import matplotlib.pyplot as plt
202+
from unittest import mock
203+
fig = plt.figure()
204+
prop = "tkinter.filedialog.asksaveasfilename"
205+
with mock.patch(prop, return_value=("foobar.png", None)):
206+
fname = fig.canvas.manager.toolbar.save_figure()
207+
os.remove("foobar.png")
208+
assert fname == "foobar.png"
209+
print("success")
210+
211+
199212
@_isolated_tk_test(success_count=1)
200213
def test_canvas_focus():
201214
import tkinter as tk

0 commit comments

Comments
 (0)