I'm trying to get into a better testing flow with Django. One of
things I'm trying to figure out how to test are templates. Using the
Django Test Client works fine, for instance, in detecting whether I
have a missing template tag (because it'll explode) or if I don't pass
a particular variable to the context (using the response's context
attribute).

There are a couple of other things I'd like to automate testing of
however.

1) Has a template variable been used? Sometimes I'll have a piece of
template code like this : {% if a %}{{ b }}{% else %}{{ c }}{% end %},
and I'd like to see whether b or c has been rendered.

2) Were there any attribute errors? E.g. if variable x has no
attribute y, I should be able to detect something wrong with
{{ x.y.z }}. This is currently hidden by Django's silent failure when
dealing with template variables.

Currently, I'm doing a bit of testing using this pattern:

assert "something" in response.content, response.content

That's somewhat messy however -- and I'd like to avoid having to scan
through html in my test output just to find a bug if there's a simpler
method. Does anyone have any suggestions?

-- Andrew


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to