diff options
| author | David Hoffman <me@davidhoffman.ca> | 2016-12-08 19:17:02 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-12-15 10:35:44 -0500 |
| commit | bf84d042e0bba636fe2199051fe25e96d89865da (patch) | |
| tree | 119470db1a6f0f6d5de6b66f71929c92a6a4e97f /tests/postgres_tests | |
| parent | 9524fd9133e47fa90846904f81fe91c72f331e56 (diff) | |
Fixed #27582 -- Allowed HStoreField to store null values.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_hstore.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_hstore.py b/tests/postgres_tests/test_hstore.py index fef71f1ef4..0fc427f67c 100644 --- a/tests/postgres_tests/test_hstore.py +++ b/tests/postgres_tests/test_hstore.py @@ -195,7 +195,11 @@ class TestValidation(HStoreTestCase): with self.assertRaises(exceptions.ValidationError) as cm: field.clean({'a': 1}, None) self.assertEqual(cm.exception.code, 'not_a_string') - self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string.') + self.assertEqual(cm.exception.message % cm.exception.params, 'The value of "a" is not a string or null.') + + def test_none_allowed_as_value(self): + field = HStoreField() + self.assertEqual(field.clean({'a': None}, None), {'a': None}) class TestFormField(HStoreTestCase): @@ -224,6 +228,11 @@ class TestFormField(HStoreTestCase): value = field.clean('{"a": 1}') self.assertEqual(value, {'a': '1'}) + def test_none_value(self): + field = forms.HStoreField() + value = field.clean('{"a": null}') + self.assertEqual(value, {'a': None}) + def test_empty(self): field = forms.HStoreField(required=False) value = field.clean('') |
