summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrad Melin <melinbrad@gmail.com>2016-05-29 14:17:07 +0200
committerTim Graham <timograham@gmail.com>2016-06-02 16:28:01 -0400
commitf6517a5335ccc4858ee540548a1bd162bec36c46 (patch)
treeec9ca118fc59c77a3c05cbef51fab714d6c11410 /tests
parentabc522383454493e6341bfe7307143440d9ee7ac (diff)
Fixed #26672 -- Fixed HStoreField to raise ValidationError instead of crashing on non-dict JSON input.
Diffstat (limited to 'tests')
-rw-r--r--tests/postgres_tests/test_hstore.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_hstore.py b/tests/postgres_tests/test_hstore.py
index 8ebd757098..b927d8e19f 100644
--- a/tests/postgres_tests/test_hstore.py
+++ b/tests/postgres_tests/test_hstore.py
@@ -208,6 +208,13 @@ class TestFormField(PostgreSQLTestCase):
self.assertEqual(cm.exception.messages[0], 'Could not load JSON data.')
self.assertEqual(cm.exception.code, 'invalid_json')
+ def test_non_dict_json(self):
+ field = forms.HStoreField()
+ msg = 'Input must be a JSON dictionary.'
+ with self.assertRaisesMessage(exceptions.ValidationError, msg) as cm:
+ field.clean('["a", "b", 1]')
+ self.assertEqual(cm.exception.code, 'invalid_format')
+
def test_not_string_values(self):
field = forms.HStoreField()
value = field.clean('{"a": 1}')