pytex/tests/test_pytex.py

62 lines
1.3 KiB
Python

#!/usr/bin/env python
# encoding: utf-8
from pytex import feed, pdflatex, clean
import os
from shutil import copyfile
from pathlib import Path
import pytest
TESTDIR = Path("tests")
GOOD_TEMPLATE = TESTDIR / "tpl_good.tex"
GOOD_DATA = {
"name": "Bob",
"repetitions": 4,
}
@pytest.fixture()
def prepare_templates(tmpdir):
wdir = tmpdir
good_tpl = Path(GOOD_TEMPLATE)
copyfile(good_tpl, wdir / good_tpl.name)
prev_cwd = Path.cwd()
os.chdir(wdir)
yield wdir
os.chdir(prev_cwd)
def test_feed_once(prepare_templates):
output = feed(GOOD_TEMPLATE.name, GOOD_DATA)
def test_feed_twice(prepare_templates):
output1 = feed(GOOD_TEMPLATE.name, GOOD_DATA)
output2 = feed(GOOD_TEMPLATE.name, GOOD_DATA)
def test_feed_output(prepare_templates):
dest = "./tests/special_name.tex"
output = feed(GOOD_TEMPLATE.name, GOOD_DATA, dest)
assert output.samefile(dest)
def test_feed_output_noforce():
pass
# output = feed(GOOD_TEMPLATE, GOOD_DATA, )
# os.system(f"rm {output}")
def test_feed_pdflatex(prepare_templates):
latex_file = feed(GOOD_TEMPLATE.name, GOOD_DATA)
pdflatex(latex_file)
clean(garbages=["*.aux", "*.log", "*.pdf"])
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del