@@ -61,6 +61,7 @@ def _get_testable_interactive_backends():
6161_test_script = """\
6262 import importlib
6363import importlib.util
64+ import io
6465import json
6566import sys
6667from unittest import TestCase
@@ -120,7 +121,23 @@ def check_alt_backend(alt_backend):
120121fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
121122fig.canvas.mpl_connect("close_event", print)
122123
124+ result = io.BytesIO()
125+ fig.savefig(result, format='png')
126+
123127plt.show()
128+
129+ # Ensure that the window is really closed.
130+ plt.pause(0.5)
131+
132+ # Test that saving works after interactive window is closed, but the figure is
133+ # not deleted.
134+ result_after = io.BytesIO()
135+ fig.savefig(result_after, format='png')
136+
137+ if not backend.startswith('qt5') and sys.platform == 'darwin':
138+ # FIXME: This should be enabled everywhere once Qt5 is fixed on macOS to
139+ # not resize incorrectly.
140+ assert_equal(result.getvalue(), result_after.getvalue())
124141"""
125142_test_timeout = 10 # Empirically, 1s is not enough on Travis.
126143
@@ -134,7 +151,8 @@ def test_interactive_backend(backend, toolbar):
134151 proc = subprocess .run (
135152 [sys .executable , "-c" , _test_script ,
136153 json .dumps ({"toolbar" : toolbar })],
137- env = {** os .environ , "MPLBACKEND" : backend }, timeout = _test_timeout ,
154+ env = {** os .environ , "MPLBACKEND" : backend , "SOURCE_DATE_EPOCH" : "0" },
155+ timeout = _test_timeout ,
138156 stdout = subprocess .PIPE , universal_newlines = True )
139157 if proc .returncode :
140158 pytest .fail ("The subprocess returned with non-zero exit status "
@@ -148,7 +166,8 @@ def test_interactive_backend(backend, toolbar):
148166def test_webagg ():
149167 pytest .importorskip ("tornado" )
150168 proc = subprocess .Popen ([sys .executable , "-c" , _test_script ],
151- env = {** os .environ , "MPLBACKEND" : "webagg" })
169+ env = {** os .environ , "MPLBACKEND" : "webagg" ,
170+ "SOURCE_DATE_EPOCH" : "0" })
152171 url = "http://{}:{}" .format (
153172 mpl .rcParams ["webagg.address" ], mpl .rcParams ["webagg.port" ])
154173 timeout = time .perf_counter () + _test_timeout
0 commit comments