summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorşuayip üzülmez <suayip.541@gmail.com>2023-06-17 00:34:47 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-06-18 14:32:51 +0200
commit0c5146523b614783b60ba9f9222769dff83c776c (patch)
tree2206c5f239ef653ae095585fe6410a73f517ec50 /tests/postgres_tests/test_array.py
parent17cdc7395ed4606bfcbd3bebcaae66a0b5d88188 (diff)
Fixed #34662 -- Corrected number in error messages for Array(Min/Max)LengthValidator.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 5f8441ba1b..48b03c626a 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -990,6 +990,13 @@ class TestValidation(PostgreSQLSimpleTestCase):
"List contains 4 items, it should contain no more than 3.",
)
+ def test_with_size_singular(self):
+ field = ArrayField(models.IntegerField(), size=1)
+ field.clean([1], None)
+ msg = "List contains 2 items, it should contain no more than 1."
+ with self.assertRaisesMessage(exceptions.ValidationError, msg):
+ field.clean([1, 2], None)
+
def test_nested_array_mismatch(self):
field = ArrayField(ArrayField(models.IntegerField()))
field.clean([[1, 2], [3, 4]], None)
@@ -1132,6 +1139,13 @@ class TestSimpleFormField(PostgreSQLSimpleTestCase):
"List contains 3 items, it should contain no fewer than 4.",
)
+ def test_min_length_singular(self):
+ field = SimpleArrayField(forms.IntegerField(), min_length=2)
+ field.clean([1, 2])
+ msg = "List contains 1 item, it should contain no fewer than 2."
+ with self.assertRaisesMessage(exceptions.ValidationError, msg):
+ field.clean([1])
+
def test_required(self):
field = SimpleArrayField(forms.CharField(), required=True)
with self.assertRaises(exceptions.ValidationError) as cm: