1111
1212baseline_dir , result_dir = _image_directories (lambda : 'dummy func' )
1313
14- def run (* args ):
15- try :
16- subprocess .check_output (args )
17- return True
18- except :
19- return False
14+ def check_for (texsystem ):
15+ header = r"""
16+ \documentclass{minimal}
17+ \usepackage{pgf}
18+ \begin{document}
19+ \typeout{pgfversion=\pgfversion}
20+ \makeatletter
21+ \@@end
22+ """
23+ latex = subprocess .Popen (["xelatex" , "-halt-on-error" ],
24+ stdin = subprocess .PIPE ,
25+ stdout = subprocess .PIPE )
26+ stdout , stderr = latex .communicate (header .encode ("utf8" ))
27+
28+ return latex .returncode == 0
2029
2130def switch_backend (backend ):
2231 import nose
@@ -58,7 +67,7 @@ def create_figure():
5867
5968
6069# test compiling a figure to pdf with xelatex
61- @knownfailureif (not run ('xelatex' , '-v' ), msg = " xelatex is required for this test" )
70+ @knownfailureif (not check_for ('xelatex' ), msg = ' xelatex + pgf is required' )
6271@switch_backend ('pgf' )
6372def test_xelatex ():
6473 rc_xelatex = {'font.family' : 'serif' ,
@@ -69,7 +78,7 @@ def test_xelatex():
6978
7079
7180# test compiling a figure to pdf with pdflatex
72- @knownfailureif (not run ('pdflatex' , '-v' ), msg = " pdflatex is required for this test" )
81+ @knownfailureif (not check_for ('pdflatex' ), msg = ' pdflatex + pgf is required' )
7382@switch_backend ('pgf' )
7483def test_pdflatex ():
7584 rc_pdflatex = {'font.family' : 'serif' ,
@@ -83,8 +92,8 @@ def test_pdflatex():
8392
8493
8594# test updating the rc parameters for each figure
86- @knownfailureif (not run ( 'pdflatex' , '-v' ) or not run ( 'xelatex' , '-v ' ),
87- msg = "xelatex and pdflatex are required for this test " )
95+ @knownfailureif (not check_for ( 'xelatex' ) or not check_for ( 'pdflatex ' ),
96+ msg = "xelatex and pdflatex + pgf required " )
8897@switch_backend ('pgf' )
8998def test_rcupdate ():
9099 rc_sets = []
0 commit comments