diff options
| author | Imran Iqbal <iqbalmy@hotmail.com> | 2017-10-31 00:03:52 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-07 15:07:03 -0500 |
| commit | 3e7497a05e7f7cf0ff157d88cef18e95e3cff57b (patch) | |
| tree | 0469a2627d89aecfbd94c9c50cf937483fb90822 /tests/postgres_tests | |
| parent | 1b7780ea0802116eeef80b398a0432ac3f0ba9ef (diff) | |
Fixed #28758 -- Fixed RangeMax/MinValueValidators crash with unbound ranges.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_ranges.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index d87ad36438..f368736384 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -408,18 +408,24 @@ class TestValidators(PostgreSQLTestCase): def test_max(self): validator = RangeMaxValueValidator(5) validator(NumericRange(0, 5)) + msg = 'Ensure that this range is completely less than or equal to 5.' with self.assertRaises(exceptions.ValidationError) as cm: validator(NumericRange(0, 10)) - self.assertEqual(cm.exception.messages[0], 'Ensure that this range is completely less than or equal to 5.') + self.assertEqual(cm.exception.messages[0], msg) self.assertEqual(cm.exception.code, 'max_value') + with self.assertRaisesMessage(exceptions.ValidationError, msg): + validator(NumericRange(0, None)) # an unbound range def test_min(self): validator = RangeMinValueValidator(5) validator(NumericRange(10, 15)) + msg = 'Ensure that this range is completely greater than or equal to 5.' with self.assertRaises(exceptions.ValidationError) as cm: validator(NumericRange(0, 10)) - self.assertEqual(cm.exception.messages[0], 'Ensure that this range is completely greater than or equal to 5.') + self.assertEqual(cm.exception.messages[0], msg) self.assertEqual(cm.exception.code, 'min_value') + with self.assertRaisesMessage(exceptions.ValidationError, msg): + validator(NumericRange(None, 10)) # an unbound range class TestFormField(PostgreSQLTestCase): |
