Feat: test in tmp dir and few bug correction
This commit is contained in:
@@ -3,42 +3,56 @@
|
||||
|
||||
from pytex import feed, pdflatex, clean
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
TESTDIR = "tests"
|
||||
GOOD_TEMPLATE = TESTDIR + "/tpl_good.tex"
|
||||
WRONG_TEMPLATE = TESTDIR + "/tpl_wrong.tex"
|
||||
TESTDIR = Path("tests")
|
||||
GOOD_TEMPLATE = TESTDIR / "tpl_good.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}")
|
||||
@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():
|
||||
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)
|
||||
|
||||
def test_feed_pdflatex(prepare_templates):
|
||||
latex_file = feed(GOOD_TEMPLATE.name, GOOD_DATA)
|
||||
pdflatex(latex_file)
|
||||
os.system(f"rm {latex_file}")
|
||||
clean(TESTDIR, ["*.aux", "*.log", "*.pdf"])
|
||||
clean(garbages=["*.aux", "*.log", "*.pdf"])
|
||||
|
||||
|
||||
# -----------------------------
|
||||
|
Reference in New Issue
Block a user