I've been using webtest
for unit testing, but that only takes me so far when using templating with google app engine.
The only related info I found was how to unittest the template variables passed to jinja2 template from webapp2 request handler
However, I found it hard to digest.
The web lacks info on this as well.
A snippet of my code in one of my handlers is:
template_values = {
"message": "Ello Mate",
"errors": self.error_message,
"stats" : self.statuses
}
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.out.write(template.render(template_values))
Is there a good way to check the template values without just printing out the response?
Adam is right; you could mock it, and that might suit your needs perfectly. Alternatively, this post has information on getting Jinja2 working without mocking it. Then you could use HTMLParser to look for the template_values
in the HTML response (give their html elements unique id's to make that easier).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.