Fix test: compile_latex_document()

This commit is contained in:
Takeshi KOMIYA 2019-02-03 23:54:22 +09:00
parent b40ad9ffd4
commit 7b1755d21b

View File

@ -23,7 +23,7 @@ from sphinx.config import Config
from sphinx.errors import SphinxError from sphinx.errors import SphinxError
from sphinx.testing.util import strip_escseq from sphinx.testing.util import strip_escseq
from sphinx.util import docutils from sphinx.util import docutils
from sphinx.util.osutil import ensuredir from sphinx.util.osutil import cd, ensuredir
from sphinx.writers.latex import LaTeXTranslator from sphinx.writers.latex import LaTeXTranslator
@ -54,15 +54,16 @@ def kpsetest(*filenames):
def compile_latex_document(app, filename='python.tex'): def compile_latex_document(app, filename='python.tex'):
# now, try to run latex over it # now, try to run latex over it
try: try:
ensuredir(app.config.latex_engine) with cd(app.outdir):
# keep a copy of latex file for this engine in case test fails ensuredir(app.config.latex_engine)
copyfile(filename, app.config.latex_engine + '/' + filename) # keep a copy of latex file for this engine in case test fails
args = [app.config.latex_engine, copyfile(filename, app.config.latex_engine + '/' + filename)
'--halt-on-error', args = [app.config.latex_engine,
'--interaction=nonstopmode', '--halt-on-error',
'-output-directory=%s' % app.config.latex_engine, '--interaction=nonstopmode',
filename] '-output-directory=%s' % app.config.latex_engine,
subprocess.run(args, stdout=PIPE, stderr=PIPE, cwd=app.outdir, check=True) filename]
subprocess.run(args, stdout=PIPE, stderr=PIPE, check=True)
except OSError: # most likely the latex executable was not found except OSError: # most likely the latex executable was not found
raise pytest.skip.Exception raise pytest.skip.Exception
except CalledProcessError as exc: except CalledProcessError as exc: