1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
from pathlib import Path
from plasTeX.TeX import TeX
from plasTeX import Command
class foo(Command):
def invoke(self, tex):
self.data = tex.currentInput[0].filename
def test_input(tmpdir):
with tmpdir.as_cwd():
Path("input.tex").write_text(r'''
\documentclass{article}
\begin{document}
\input{input2}
\end{document}
''')
Path("input2.tex").write_text(r'\foo')
tex = TeX(file="input.tex")
tex.ownerDocument.context.contexts[0]["foo"] = foo
assert "./input2.tex" == tex.parse().getElementsByTagName("foo")[0].data
def test_input_without_kpsewhich(tmpdir):
with tmpdir.as_cwd():
Path("input.tex").write_text(r'''
\documentclass{article}
\begin{document}
\input{input2.tex}
\end{document}
''')
Path("input2.tex").write_text(r'\foo')
tex = TeX(file="input.tex")
tex.ownerDocument.context.contexts[0]["foo"] = foo
tex.ownerDocument.config['general']['kpsewhich'] = ''
assert "./input2.tex" == tex.parse().getElementsByTagName("foo")[0].data
def test_input_without_kpsewhich_without_extension(tmpdir):
with tmpdir.as_cwd():
Path("input.tex").write_text(r'''
\documentclass{article}
\begin{document}
\input{input2}
\end{document}
''')
Path("input2.tex").write_text(r'\foo')
tex = TeX(file="input.tex")
tex.ownerDocument.context.contexts[0]["foo"] = foo
tex.ownerDocument.config['general']['kpsewhich'] = ''
assert "./input2.tex" == tex.parse().getElementsByTagName("foo")[0].data
|