@@ -119,14 +119,15 @@ def test_bold_font_output_with_none_fonttype():
119
119
ax .set_title ('bold-title' , fontweight = 'bold' )
120
120
121
121
122
- def _test_determinism (filename ):
122
+ def _test_determinism_save (filename , usetex ):
123
123
# This function is mostly copy&paste from "def test_visibility"
124
124
# To require no GUI, we use Figure and FigureCanvasSVG
125
125
# instead of plt.figure and fig.savefig
126
126
from matplotlib .figure import Figure
127
127
from matplotlib .backends .backend_svg import FigureCanvasSVG
128
128
from matplotlib import rc
129
129
rc ('svg' , hashsalt = 'asdf' )
130
+ rc ('text' , usetex = usetex )
130
131
131
132
fig = Figure ()
132
133
ax = fig .add_subplot (111 )
@@ -138,12 +139,14 @@ def _test_determinism(filename):
138
139
a , b , c = ax .errorbar (x , y , yerr = yerr , fmt = 'ko' )
139
140
for artist in b :
140
141
artist .set_visible (False )
142
+ ax .set_title ('A string $1+2+\sigma$' )
143
+ ax .set_xlabel ('A string $1+2+\sigma$' )
144
+ ax .set_ylabel ('A string $1+2+\sigma$' )
141
145
142
146
FigureCanvasSVG (fig ).print_svg (filename )
143
147
144
148
145
- @cleanup
146
- def test_determinism ():
149
+ def _test_determinism (filename , usetex ):
147
150
import os
148
151
import sys
149
152
from subprocess import check_call
@@ -154,15 +157,27 @@ def test_determinism():
154
157
'import matplotlib; '
155
158
'matplotlib.use("svg"); '
156
159
'from matplotlib.tests.test_backend_svg '
157
- 'import _test_determinism ;'
158
- '_test_determinism("determinism.svg")' ])
159
- with open ('determinism.svg' , 'rb' ) as fd :
160
+ 'import _test_determinism_save ;'
161
+ '_test_determinism_save(%r, %r)' % ( filename , usetex ) ])
162
+ with open (filename , 'rb' ) as fd :
160
163
plots .append (fd .read ())
161
- os .unlink ('determinism.svg' )
164
+ os .unlink (filename )
162
165
for p in plots [1 :]:
163
166
assert_equal (p , plots [0 ])
164
167
165
168
169
+ @cleanup
170
+ def test_determinism_notex ():
171
+ # unique filename to allow for parallel testing
172
+ _test_determinism ('determinism_notex.svg' , usetex = False )
173
+
174
+
175
+ @cleanup
176
+ def test_determinism_tex ():
177
+ # unique filename to allow for parallel testing
178
+ _test_determinism ('determinism_tex.svg' , usetex = True )
179
+
180
+
166
181
if __name__ == '__main__' :
167
182
import nose
168
183
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments