diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-20 11:33:02 +0000 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-02-20 11:51:46 +0000 |
| commit | c490e410af086fa89f40d515505bba02a08168f3 (patch) | |
| tree | ce68fc055f0f93e2bc1e7ac57d997b7943b53f15 /tests/postgres_tests | |
| parent | 32d4db66b999cde6776d4be7f71528dab94916cc (diff) | |
Fixed #24373 -- Added run_validators to ArrayField.
Thanks to DavidMuller for the report.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_array.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 88e34f9ce4..35a3bffd58 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -6,7 +6,7 @@ import uuid from django import forms from django.contrib.postgres.fields import ArrayField from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField -from django.core import exceptions, serializers +from django.core import exceptions, serializers, validators from django.core.management import call_command from django.db import IntegrityError, connection, models from django.test import TestCase, TransactionTestCase, override_settings @@ -330,6 +330,14 @@ class TestValidation(TestCase): self.assertEqual(cm.exception.code, 'nested_array_mismatch') self.assertEqual(cm.exception.messages[0], 'Nested arrays must have the same length.') + def test_with_validators(self): + field = ArrayField(models.IntegerField(validators=[validators.MinValueValidator(1)])) + field.clean([1, 2], None) + with self.assertRaises(exceptions.ValidationError) as cm: + field.clean([0], None) + self.assertEqual(cm.exception.code, 'item_invalid') + self.assertEqual(cm.exception.messages[0], 'Item 0 in the array did not validate: Ensure this value is greater than or equal to 1.') + class TestSimpleFormField(TestCase): |
