python - py.test is failing to deal with creating files -


i have program creating multitude of latex files 1 one. important when creating these latex files check can compile .pdf without error.

to uses subprocess.call(['pdflatex', '-halt-on-error', tex_file_name]).

which returns 0 on successful compile .tex .pdf, , 1 otherwise.

the problem having circumstance under line of code not think should do, when py.test runs it. if run code interpreter, or running script command line, works. py.test doesn't.

when py.test errors, leaves behind log file created pdflatex, has error in it:

{c:/texlive/2012/texmf-var/fonts/map/pdftex/updmap/pdftex.map !pdftex error: pdflatex.exe (file c:/texlive/2012/texmf-var/fonts/map/pdftex/up dmap/pdftex.map): fflush() failed (bad file descriptor)  ==> fatal error occurred, no output pdf file produced! 

i hazarding guess here py.test doing some thing .tex file prior pdflatex being able compile it. don't know what.

temporary files , directories talked in py.test docs. don't know if relevant problem, have played around them briefly.

in case want @ code, test case looks this:

from import foo b import tree latex_tester import latex_tester   def test_foo():     q1 = foo.foo()     latex_tester(tree(1, q1)) 

and latex_tester looks this:

import uuid import os import subprocess   def latex_tester(tree):     """ test whether latex compilable pdf.      """       full_path = r'some_path'     uid = str(uuid.uuid1())      file_name = os.path.join(full_path, 'test' + uid + '.tex')      open(file_name, 'w') f:         _write_tree(f, tree)      retcode = subprocess.call(['pdflatex', '-halt-on-error', file_name])     if retcode != 0:         raise runtimeerror("this latex not compiled.") 

oddly enough, using 'xelatex' instead of 'pdflatex' makes things work normal.

for future readers - have texworks installed presumably installed both these tools. don't know if xelatex influences final pdf produced. seems producing .pdf

anyway, made answer own question since there doesn't seem else coming , solved problem.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -