summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_datastructures.py
diff options
context:
space:
mode:
authorAnton Baklanov <antonbaklanov@gmail.com>2013-04-17 18:20:31 +0300
committerClaude Paroz <claude@2xlibre.net>2013-04-19 10:08:16 +0200
commit59d127e45f5ed31e346162a0ac312f672c096821 (patch)
tree2b89e419f1d7e69ce93aad0412b9061162c9edfe /tests/utils_tests/test_datastructures.py
parentbfe25de42993fdbfccd4759f48ac6694e1ed32d9 (diff)
downloaddjango-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.py7
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):