Feat: add test and pyPath to pathlib

This commit is contained in:
2019-12-22 17:30:23 +01:00
parent ab850bcedb
commit 6a130d0086
3 changed files with 73 additions and 8 deletions

47
tests/test_pytex.py Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python
# encoding: utf-8
from pytex import feed, pdflatex, clean
import os
TESTDIR = "tests"
GOOD_TEMPLATE = TESTDIR + "/tpl_good.tex"
WRONG_TEMPLATE = TESTDIR + "/tpl_wrong.tex"
GOOD_DATA = {
"name": "Bob",
"repetitions": 4,
}
def test_feed_once():
output = feed(GOOD_TEMPLATE, GOOD_DATA)
os.system(f"rm {output}")
def test_feed_twice():
output1 = feed(GOOD_TEMPLATE, GOOD_DATA)
output2 = feed(GOOD_TEMPLATE, GOOD_DATA)
os.system(f"rm {output1}")
os.system(f"rm {output2}")
def test_feed_output():
dest = "./tests/special_name.tex"
output = feed(GOOD_TEMPLATE, GOOD_DATA, dest)
assert(output.samefile(dest))
os.system(f"rm {output}")
def test_feed_output_noforce():
pass
# output = feed(GOOD_TEMPLATE, GOOD_DATA, )
# os.system(f"rm {output}")
def test_feed_pdflatex():
latex_file = feed(GOOD_TEMPLATE, GOOD_DATA)
pdflatex(latex_file)
os.system(f"rm {latex_file}")
clean(TESTDIR, ["*.aux", "*.log", "*.pdf"])
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del

15
tests/tpl_good.tex Normal file
View File

@@ -0,0 +1,15 @@
\documentclass{article}
\usepackage[utf8]{inputenc} % Unicode support (Umlauts etc.)
\usepackage[french]{babel} % Change hyphenation rules
\begin{document}
Coucou comment allez vous?
Je m'appelle \Var{name}.
%- for j in range(repetitions)
Je peux faire \Var{j} \\
%- endfor
\end{document}