8000 Add test for pgf.documentclass rcParam in PGF backend · matplotlib/matplotlib@852824b · GitHub
[go: up one dir, main page]

Skip to content

Commit 852824b

Browse files
committed
Add test for pgf.documentclass rcParam in PGF backend
1 parent db774e3 commit 852824b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,37 @@ def test_document_font_size():
400400
label=r'\normalsize the document font size is \the\fontdimen6\font'
401401
)
402402
plt.legend()
403+
404+
405+
@needs_pgf_pdflatex
406+
@pytest.mark.backend("pgf")
407+
def test_pgf_documentclass_written():
408+
import pathlib
409+
from tempfile import TemporaryDirectory
410+
# Set custom documentclass
411+
mpl.rcParams["pgf.texsystem"] = "pdflatex"
412+
mpl.rcParams["pgf.documentclass"] = "IEEEtran"
413+
414+
with TemporaryDirectory() as tmpdir:
415+
tmpdir = pathlib.Path(tmpdir)
416+
texfile = tmpdir / "figure.tex"
417+
pgffile = tmpdir / "figure.pgf"
418+
419+
# Generate PGF figure
420+
fig, ax = plt.subplots()
421+
ax.plot([1, 2, 3], [4, 5, 6])
422+
fig.savefig(pgffile, format="pgf")
423+
424+
# Manually generate .tex using PGF backend logic
425+
texfile.write_text(
426+
"\n".join([
427+
r"\documentclass{IEEEtran}",
428+
r"\usepackage{pgf}",
429+
r"\begin{document}",
430+
r"\input{figure.pgf}",
431+
r"\end{document}"
432+
])
433+
)
434+
435+
content = texfile.read_text()
436+
assert r"\documentclass{IEEEtran}" in content

0 commit comments

Comments
 (0)
0