@@ -46,9 +46,9 @@ def check_for(texsystem):
46
46
reason = 'lualatex + pgf is required' )
47
47
48
48
49
- def _has_sfmath ( ):
49
+ def _has_tex_package ( package ):
50
50
return (shutil .which ("kpsewhich" )
51
- and subprocess .run (["kpsewhich" , "sfmath .sty" ],
51
+ and subprocess .run (["kpsewhich" , f" { package } .sty" ],
52
52
stdout = subprocess .PIPE ).returncode == 0 )
53
53
54
54
@@ -113,6 +113,7 @@ def test_xelatex():
113
113
114
114
# test compiling a figure to pdf with pdflatex
115
115
@needs_pdflatex
116
+ @pytest .mark .skipif (not _has_tex_package ('ucs' ), reason = 'needs ucs.sty' )
116
117
@pytest .mark .backend ('pgf' )
117
118
@image_comparison (['pgf_pdflatex.pdf' ], style = 'default' )
118
119
def test_pdflatex ():
@@ -132,7 +133,6 @@ def test_pdflatex():
132
133
# test updating the rc parameters for each figure
133
134
@needs_xelatex
134
135
@needs_pdflatex
135
- @pytest .mark .skipif (not _has_sfmath (), reason = 'needs sfmath.sty' )
136
136
@pytest .mark .style ('default' )
137
137
@pytest .mark .backend ('pgf' )
138
138
def test_rcupdate ():
@@ -154,6 +154,10 @@ def test_rcupdate():
154
154
tol = [6 , 0 ]
155
155
for i , rc_set in enumerate (rc_sets ):
156
156
with mpl .rc_context (rc_set ):
157
+ for substring , pkg in [('sfmath' , 'sfmath' ), ('utf8x' , 'ucs' )]:
158
+ if (substring in mpl .rcParams ['pgf.preamble' ]
159
+ and not _has_tex_package (pkg )):
160
+ pytest .skip (f'needs { pkg } .sty' )
157
161
create_figure ()
158
162
compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ), tol = tol [i ])
159
163
0 commit comments