diff options
author | Anton Baklanov <antonbaklanov@gmail.com> | 2013-04-17 18:20:31 +0300 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2013-04-19 10:08:16 +0200 |
commit | 59d127e45f5ed31e346162a0ac312f672c096821 (patch) | |
tree | 2b89e419f1d7e69ce93aad0412b9061162c9edfe /tests/utils_tests/test_datastructures.py | |
parent | bfe25de42993fdbfccd4759f48ac6694e1ed32d9 (diff) | |
download | django-59d127e45f5ed31e346162a0ac312f672c096821.tar.gz |
Fixed #20276 -- Implemented __bool__ for MergeDict
MergeDict evaluates now to False if all contained dicts are empty.
Thanks til for the report and the initial patch.
Diffstat (limited to 'tests/utils_tests/test_datastructures.py')
-rw-r--r-- | tests/utils_tests/test_datastructures.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py index 3161c04f97..91111cc2ed 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -203,6 +203,13 @@ class MergeDictTests(SimpleTestCase): ('key2', ['value2', 'value3']), ('key4', ['value5', 'value6'])]) + def test_bool_casting(self): + empty = MergeDict({}, {}, {}) + not_empty = MergeDict({}, {}, {"key": "value"}) + self.assertFalse(empty) + self.assertTrue(not_empty) + + class MultiValueDictTests(SimpleTestCase): def test_multivaluedict(self): |