Gary Wilson wrote:
> Russell then added the comments:
> -------------
> My hesitation here (and the reason I didn't include a 'context assert' in the
> first place) is that assertContext does an Equals test, but doesn't provide a
> way to do any other assertion - NotEquals?, True, False, LessThan?, etc. We
> could get around this by adding assertContextEquals, assertContextNotEquals,
> and so on, but that is really just duplicating the underlying assertion API.
> This is certainly possible, but I'm not convinced it is the best approach.
> 
> An alternate approach would be to provide a utility function to get the value
> of a context variable from the list of contexts in a response. This would
> allow the use of all the standard assert methods. However, I'm not entirely
> sure where such a utility function should go. Putting it on the TestCase?
> itself rubs me the wrong way.
> -------------

What would happen in the case where the same variable name is used in multiple
contexts with different values in each context?  Do the various other assert
methods (True, False, etc.) even make sense in that case?

On a related note, is the lack of some sort of assertContext method the reason
why in django.test.client.Client.request that we are flattening out a
single-item list of templates and contexts to the single item?  I ask because
in the TestCase code, we are turning the single item back into a single-item
list.  Could we just keep it a list and forgo the flattening and unflattening?

There is test code in modeltests.test_client that is relying on the a
single-item list of contexts being flattened out to a single context item:

self.assertEqual(response.context['data'], '37')

But this would not work when multiple contexts were used for rendering.
Is there any other reason for the flattening?

Gary

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to