In the unittest
style, I can test that a page uses a particular template by calling assertTemplateUsed
. This is useful, for example, when Django inserts values through a template, so that I can't just test string equality.
How should I write the equivalent statement in pytest?
I've been looking in pytest-django but don't see how to do it.
_assert_template_used
show there is an attribute.templates
inreponse
. So you need something likeassert response.templates and ('mytemplate' in [t.name for t in response.templates if t.name is not None])
. – Jordison