pytex/tests/test_pytex.py

62 lines
1.3 KiB
Python
Raw Normal View History

2019-12-22 16:30:23 +00:00
#!/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
2019-12-22 16:30:23 +00:00
TESTDIR = Path("tests")
GOOD_TEMPLATE = TESTDIR / "tpl_good.tex"
2019-12-22 16:30:23 +00:00
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)
2019-12-22 16:30:23 +00:00
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)
2019-12-22 16:30:23 +00:00
pdflatex(latex_file)
clean(garbages=["*.aux", "*.log", "*.pdf"])
2019-12-22 16:30:23 +00:00
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del