Added test script for TemplateError trapping
This commit is contained in:
parent
3b221fb0c6
commit
0a3627d23a
15
tests/template_error.py
Normal file
15
tests/template_error.py
Normal file
@ -0,0 +1,15 @@
|
||||
from docxtpl import DocxTemplate, RichText
|
||||
from jinja2.exceptions import TemplateError
|
||||
|
||||
try:
|
||||
tpl = DocxTemplate('test_files/template_error_tpl.docx')
|
||||
tpl.render({
|
||||
'test_variable' : 'test variable value'
|
||||
})
|
||||
except TemplateError as the_error:
|
||||
print unicode(the_error)
|
||||
if hasattr(the_error, 'docx_context'):
|
||||
print "Context:"
|
||||
for line in the_error.docx_context:
|
||||
print line
|
||||
tpl.save('test_files/template_error.docx')
|
||||
BIN
tests/test_files/template_error.docx
Normal file
BIN
tests/test_files/template_error.docx
Normal file
Binary file not shown.
BIN
tests/test_files/template_error_tpl.docx
Normal file
BIN
tests/test_files/template_error_tpl.docx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user