11
11
12
12
baseline_dir , result_dir = _image_directories (lambda : 'dummy func' )
13
13
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
20
29
21
30
def switch_backend (backend ):
22
31
import nose
@@ -58,7 +67,7 @@ def create_figure():
58
67
59
68
60
69
# 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' )
62
71
@switch_backend ('pgf' )
63
72
def test_xelatex ():
64
73
rc_xelatex = {'font.family' : 'serif' ,
@@ -69,7 +78,7 @@ def test_xelatex():
69
78
70
79
71
80
# 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' )
73
82
@switch_backend ('pgf' )
74
83
def test_pdflatex ():
75
84
rc_pdflatex = {'font.family' : 'serif' ,
@@ -83,8 +92,8 @@ def test_pdflatex():
83
92
84
93
85
94
# 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 " )
88
97
@switch_backend ('pgf' )
89
98
def test_rcupdate ():
90
99
rc_sets = []
0 commit comments