@@ -61,6 +61,7 @@ def _get_testable_interactive_backends():
61
61
_test_script = """\
62
62
import importlib
63
63
import importlib.util
64
+ import io
64
65
import json
65
66
import sys
66
67
from unittest import TestCase
@@ -120,7 +121,20 @@ def check_alt_backend(alt_backend):
120
121
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
121
122
fig.canvas.mpl_connect("close_event", print)
122
123
124
+ result = io.BytesIO()
125
+ fig.savefig(result, format='png')
126
+
123
127
plt.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
+ assert_equal(result.getvalue(), result_after.getvalue())
124
138
"""
125
139
_test_timeout = 10 # Empirically, 1s is not enough on Travis.
126
140
@@ -134,7 +148,8 @@ def test_interactive_backend(backend, toolbar):
134
148
proc = subprocess .run (
135
149
[sys .executable , "-c" , _test_script ,
136
150
json .dumps ({"toolbar" : toolbar })],
137
- env = {** os .environ , "MPLBACKEND" : backend }, timeout = _test_timeout ,
151
+ env = {** os .environ , "MPLBACKEND" : backend , "SOURCE_DATE_EPOCH" : "0" },
152
+ timeout = _test_timeout ,
138
153
stdout = subprocess .PIPE , universal_newlines = True )
139
154
if proc .returncode :
140
155
pytest .fail ("The subprocess returned with non-zero exit status "
@@ -148,7 +163,8 @@ def test_interactive_backend(backend, toolbar):
148
163
def test_webagg ():
149
164
pytest .importorskip ("tornado" )
150
165
proc = subprocess .Popen ([sys .executable , "-c" , _test_script ],
151
- env = {** os .environ , "MPLBACKEND" : "webagg" })
166
+ env = {** os .environ , "MPLBACKEND" : "webagg" ,
167
+ "SOURCE_DATE_EPOCH" : "0" })
152
168
url = "http://{}:{}" .format (
153
169
mpl .rcParams ["webagg.address" ], mpl .rcParams ["webagg.port" ])
154
170
timeout = time .perf_counter () + _test_timeout
0 commit comments