@@ -98,65 +98,6 @@ def test_bold_font_output_with_none_fonttype():
9898 ax .set_title ('bold-title' , fontweight = 'bold' )
9999
100100
101- def _test_determinism_save (filename , usetex ):
102- # This function is mostly copy&paste from "def test_visibility"
103- mpl .rc ('svg' , hashsalt = 'asdf' )
104- mpl .rc ('text' , usetex = usetex )
105-
106- fig = Figure () # Require no GUI.
107- ax = fig .add_subplot (111 )
108-
109- x = np .linspace (0 , 4 * np .pi , 50 )
110- y = np .sin (x )
111- yerr = np .ones_like (y )
112-
113- a , b , c = ax .errorbar (x , y , yerr = yerr , fmt = 'ko' )
114- for artist in b :
115- artist .set_visible (False )
116- ax .set_title ('A string $1+2+\\ sigma$' )
117- ax .set_xlabel ('A string $1+2+\\ sigma$' )
118- ax .set_ylabel ('A string $1+2+\\ sigma$' )
119-
120- fig .savefig (filename , format = "svg" )
121-
122-
123- @pytest .mark .parametrize (
124- "filename, usetex" ,
125- # unique filenames to allow for parallel testing
126- [("determinism_notex.svg" , False ),
127- pytest .param ("determinism_tex.svg" , True , marks = needs_usetex )])
128- def test_determinism (filename , usetex ):
129- import sys
130- from subprocess import check_output , STDOUT , CalledProcessError
131- plots = []
132- for i in range (3 ):
133- # Using check_output and setting stderr to STDOUT will capture the real
134- # problem in the output property of the exception
135- try :
136- check_output (
137- [sys .executable , '-R' , '-c' ,
138- 'import matplotlib; '
139- 'matplotlib._called_from_pytest = True; '
140- 'matplotlib.use("svg", force=True); '
141- 'from matplotlib.tests.test_backend_svg '
142- 'import _test_determinism_save;'
143- '_test_determinism_save(%r, %r)' % (filename , usetex )],
144- stderr = STDOUT )
145- except CalledProcessError as e :
146- # it's easier to use utf8 and ask for forgiveness than try
147- # to figure out what the current console has as an
148- # encoding :-/
149- print (e .output .decode (encoding = "utf-8" , errors = "ignore" ))
150- raise e
151- else :
152- with open (filename , 'rb' ) as fd :
153- plots .append (fd .read ())
154- finally :
155- os .unlink (filename )
156- for p in plots [1 :]:
157- assert p == plots [0 ]
158-
159-
160101@needs_usetex
161102def test_missing_psfont (monkeypatch ):
162103 """An error is raised if a TeX font lacks a Type-1 equivalent"""
0 commit comments