summaryrefslogtreecommitdiff
path: root/django/test/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/test/utils.py')
-rw-r--r--django/test/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/django/test/utils.py b/django/test/utils.py
index 29babec3ff..d34dd33d15 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -6,6 +6,20 @@ from django.test import signals
from django.template import Template
from django.utils.translation import deactivate
+class ContextList(list):
+ """A wrapper that provides direct key access to context items contained
+ in a list of context objects.
+ """
+ def __getitem__(self, key):
+ if isinstance(key, basestring):
+ for subcontext in self:
+ if key in subcontext:
+ return subcontext[key]
+ raise KeyError
+ else:
+ return super(ContextList, self).__getitem__(key)
+
+
def instrumented_test_render(self, context):
"""
An instrumented Template render method, providing a signal