I wrote a custom loader in django which is performing some 'regular expression' changes in template and In unit testcase for the loader I want to check the changes in the template. But django loader didn't returns any template_string attribute with template object.
For Example
I am removing new line i.e. '\n' after every '%}' in the template with the help of custom loader by performing re operations over it.
Now I need to check this after loader performs re operations over template in the TestCases.
template:
{% for i in list %}\n
{{ i }}
{% endfor %}\n
in Unit Test Case:
template = loader.get_template("path/to/template")
#How I can retrieve template_string from template object?
#to put in place of 'output'
self.assertEqual(output ,"{% for i in list%}{{ i }}{% endfor %}")
The expected output I need to match is {% for i in list%}{{ i }}{% endfor %}
. How can I get the template_string from the template object?
Aucun commentaire:
Enregistrer un commentaire