Feat: add test and pyPath to pathlib
This commit is contained in:
47
tests/test_pytex.py
Normal file
47
tests/test_pytex.py
Normal 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
15
tests/tpl_good.tex
Normal 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}
|
Reference in New Issue
Block a user