Skip to content

Commit 61aec6e

Browse files
authored
Merge pull request #18872 from anntzer/pgftests
Add dependency on ucs for pgf tests using [utf8x]{inputenc}.
2 parents eeef6e5 + 3210f6a commit 61aec6e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def check_for(texsystem):
4646
reason='lualatex + pgf is required')
4747

4848

49-
def _has_sfmath():
49+
def _has_tex_package(package):
5050
return (shutil.which("kpsewhich")
51-
and subprocess.run(["kpsewhich", "sfmath.sty"],
51+
and subprocess.run(["kpsewhich", f"{package}.sty"],
5252
stdout=subprocess.PIPE).returncode == 0)
5353

5454

@@ -113,6 +113,7 @@ def test_xelatex():
113113

114114
# test compiling a figure to pdf with pdflatex
115115
@needs_pdflatex
116+
@pytest.mark.skipif(not _has_tex_package('ucs'), reason='needs ucs.sty')
116117
@pytest.mark.backend('pgf')
117118
@image_comparison(['pgf_pdflatex.pdf'], style='default')
118119
def test_pdflatex():
@@ -132,7 +133,6 @@ def test_pdflatex():
132133
# test updating the rc parameters for each figure
133134
@needs_xelatex
134135
@needs_pdflatex
135-
@pytest.mark.skipif(not _has_sfmath(), reason='needs sfmath.sty')
136136
@pytest.mark.style('default')
137137
@pytest.mark.backend('pgf')
138138
def test_rcupdate():
@@ -154,6 +154,10 @@ def test_rcupdate():
154154
tol = [6, 0]
155155
for i, rc_set in enumerate(rc_sets):
156156
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')
157161
create_figure()
158162
compare_figure('pgf_rcupdate%d.pdf' % (i + 1), tol=tol[i])
159163

0 commit comments

Comments
 (0)