Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d41a8d

Browse files
authored
Merge pull request #11076 from anntzer/dont-pollute-root-dir
Don't create texput.{aux,log} in rootdir everytime tests are run.
2 parents acfc0e2 + faeb7af commit 2d41a8d

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ examples/*/*.eps
7474
examples/*/*.svgz
7575
examples/tests/*
7676
!examples/tests/backend_driver.py
77-
texput.log
78-
texput.aux
7977
result_images
8078

8179
# Nose/Pytest generated files #

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
2+
from pathlib import Path
23
import shutil
34
import subprocess
5+
from tempfile import TemporaryDirectory
46

57
import numpy as np
68
import pytest
@@ -15,23 +17,23 @@
1517

1618

1719
def check_for(texsystem):
18-
header = """
19-
\\documentclass{minimal}
20-
\\usepackage{pgf}
21-
\\begin{document}
22-
\\typeout{pgfversion=\\pgfversion}
23-
\\makeatletter
24-
\\@@end
25-
"""
26-
try:
27-
latex = subprocess.Popen([str(texsystem), "-halt-on-error"],
28-
stdin=subprocess.PIPE,
29-
stdout=subprocess.PIPE)
30-
stdout, stderr = latex.communicate(header.encode("utf8"))
31-
except OSError:
32-
return False
33-
34-
return latex.returncode == 0
20+
with TemporaryDirectory() as tmpdir:
21+
tex_path = Path(tmpdir, "test.tex")
22+
tex_path.write_text(r"""
23+
\documentclass{minimal}
24+
\usepackage{pgf}
25+
\begin{document}
26+
\typeout{pgfversion=\pgfversion}
27+
\makeatletter
28+
\@@end
29+
""")
30+
try:
31+
subprocess.check_call(
32+
[texsystem, "-halt-on-error", str(tex_path)], cwd=tmpdir,
33+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
34+
except (OSError, subprocess.CalledProcessError):
35+
return False
36+
return True
3537

3638

3739
needs_xelatex = pytest.mark.skipif(not check_for('xelatex'),
@@ -97,7 +99,6 @@ def test_xelatex():
9799
@image_comparison(baseline_images=['pgf_pdflatex'], extensions=['pdf'],
98100
style='default')
99101
def test_pdflatex():
100-
import os
101102
if os.environ.get('APPVEYOR', False):
102103
pytest.xfail("pdflatex test does not work on appveyor due to missing "
103104
"LaTeX fonts")

0 commit comments

Comments
 (0)