On Thu, 2008-10-16 at 10:49 -0700, meppum wrote:
[...]
> closer investigation reveals that the response.context dictionary is
> somehow transformed into a list of 2 identical dictionaries. so
> instead I need to do something like this:
> 
>  self.assertEqual(len(response.context[0]['customers']), 5)
> 
> is this a bug? if what is the suggested method of testing something
> like this other than hard coding response.context[0]...?

Aah ... what a different an explanation of the problem makes. :-)

In the testing framework request.context will be a list of all the
contexts used to render the templates if more than one template was
rendered. This is documented in topics/testing.txt. It's a bit annoying
sometimes that it isn't always a list, but that's the way it is (we
certainly can't change it now, since it would be backwards incompatible)
and it's easy enough to test if it's a list or not (similarly for
request.template).

So it's not a bug. It's documented behaviour. It seems that the view you
are calling rendered two templates (possibly via a template tag, or it
sent mail that used a template as well as returning an HTML page, or it
used an "include" tag... there are lots of possibilities).

I don't understand the last part of your question, unless you are
concerned that perhaps the order in which the templates are rendered
could change (they won't -- rendering is a deterministic process). So
writing response.context[0] would be exactly the right thing to do, it
seems.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to