diff options
| author | Chris Wilson <chris+github@qwirx.com> | 2013-05-13 17:38:29 +0100 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-06-01 00:04:06 +0300 |
| commit | fa7cb4ef3cc5f4c3514857bd25b43d31815eba94 (patch) | |
| tree | 9f16661defc860f807bbebc25b74f7f8116e2321 /django | |
| parent | 5090c7b58bd3c774daf17a13d7408968f0ee8da0 (diff) | |
Fixed #20404 -- Added a keys() method to ContextList.
It's useful to be able to list all the (flattened) keys of a
ContextList, to help you figure out why the variable that's supposed
to be there is not.
No .values() or .items() added as the definition for those aren't clear.
The patch is Chris Wilson's patch from pull request 1065 with some
modifications by committer.
Diffstat (limited to 'django')
| -rw-r--r-- | django/test/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/django/test/utils.py b/django/test/utils.py index d178c9b29c..be586c75a6 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -60,6 +60,16 @@ class ContextList(list): return False return True + def keys(self): + """ + Flattened keys of subcontexts. + """ + keys = set() + for subcontext in self: + for dict in subcontext: + keys |= set(dict.keys()) + return keys + def instrumented_test_render(self, context): """ |
