diff options
| author | Brad Melin <melinbrad@gmail.com> | 2016-05-29 14:17:07 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-02 16:28:01 -0400 |
| commit | f6517a5335ccc4858ee540548a1bd162bec36c46 (patch) | |
| tree | ec9ca118fc59c77a3c05cbef51fab714d6c11410 /tests | |
| parent | abc522383454493e6341bfe7307143440d9ee7ac (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.py | 7 |
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}') |
