Bopytex/test/worker/test_compile.py

37 lines
703 B
Python
Raw Normal View History

2022-04-10 14:27:12 +00:00
import os
from pathlib import Path
2022-07-28 07:39:51 +00:00
2022-04-10 14:27:12 +00:00
import pytest
2022-07-28 07:39:51 +00:00
from bopytex.worker.compile import latexmk
2022-04-10 14:27:12 +00:00
@pytest.fixture
def tex_path(tmp_path):
source = tmp_path / "source.tex"
with open(source, "w") as src:
src.write(
"""
\\documentclass{article}
\\begin{document}
2022-07-28 07:39:51 +00:00
First document. This is a simple example, with no
2022-04-10 14:27:12 +00:00
extra parameters or packages included.
\\end{document}
"""
)
return source
2022-04-13 18:41:34 +00:00
def test_latexmk(tex_path, tmp_path):
2022-07-28 07:39:51 +00:00
# tmp_path = tex_path.parent
2022-04-10 14:27:12 +00:00
os.chdir(tmp_path)
texfile = str(tex_path.name)
output = "source.pdf"
2022-04-13 10:26:04 +00:00
message = latexmk({}, [texfile], "source.pdf")
2022-04-10 14:27:12 +00:00
2022-04-13 10:26:04 +00:00
assert message.status == 0
2022-04-10 14:27:12 +00:00
assert Path(output).exists