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:29:26 -0400 |
| commit | 95ed1514f0947a6a8f461046d15bc9273517a754 (patch) | |
| tree | 5f7bb736c6212413b8eb30e5bdf13f069f7ee2f5 /tests | |
| parent | efe89f57600f9b68e458eaf7ee6f5ab53aa65449 (diff) | |
[1.9.x] Fixed #26672 -- Fixed HStoreField to raise ValidationError instead of crashing on non-dict JSON input.
Backport of f6517a5335ccc4858ee540548a1bd162bec36c46 from master
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 f60f06c855..6bc1d62524 100644 --- a/tests/postgres_tests/test_hstore.py +++ b/tests/postgres_tests/test_hstore.py @@ -183,6 +183,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}') |
