﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13092	"ContextList objects do not support ""in"" operator"	anonymous	nobody	"When running tests, if a single template is used to product a response to an HTTP request, then the test client's response context object is a regular Context (django.template.Context) object. When multiple templates are used, however, then the test client's response context object will be a django.test.utils.ContextList object instead.

The !ContextList class tries to emulate a Context object for dictionary-style lookups, so that tests which reference response.context['key'] will still work. However, !ContextList does not implement _contains_, so expressions of the form ""'key' in request.context"", which would be true when only a single template is used, become false as soon as a second template is introduced.

For example, with this template:

{{{
<h1>No Content here</h1>
}}}

And this view:

{{{
#!python
from django.shortcuts import render_to_response
def view(request):
    return render_to_response(""test_template.html"", { ""foo"": ""bar"" })
}}}

Then a test which says:

{{{
#!python
class SimpleTest(TestCase):
    def test_context(self):
        response = self.client.get(""/test_url/"")
        self.assertTrue(""foo"" in response.context)
}}}

will succeed, but if the template is changed to this:

{{{
{% extends ""base.html"" %}
<h1>No content here</h1>
}}}

then the same test will fail. I'm attaching a patch which fixes this, as well as a two line patch for the Context/ContextList tests."		closed	Testing framework	dev		fixed	ContextList		Ready for checkin	1	0	0	0	0	0
