diff options
author | Bertrand Bordage <bordage.bertrand@gmail.com> | 2015-02-14 15:20:43 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-03-25 18:49:59 -0400 |
commit | 3e64f3d0fc285080b42b78b67565b6ed939f9a24 (patch) | |
tree | 16667272f441e98d35877c7e4357adc5ba276386 /tests/validators | |
parent | f4cc0c40a85a8cbba6d2e4cd3158070dfd8645a2 (diff) | |
download | django-3e64f3d0fc285080b42b78b67565b6ed939f9a24.tar.gz |
Fixed #24531 -- Improved CommaSeparatedIntegerField validation.
`','`, `'1,,1'`, `',1'` etc. are no longer considered as valid
comma-separated integer lists.
Diffstat (limited to 'tests/validators')
-rw-r--r-- | tests/validators/tests.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 869c6d91cb..4be4b9de4f 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -12,9 +12,9 @@ from django.core.exceptions import ValidationError from django.core.validators import ( BaseValidator, EmailValidator, MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator, RegexValidator, URLValidator, - validate_comma_separated_integer_list, validate_email, validate_integer, - validate_ipv4_address, validate_ipv6_address, validate_ipv46_address, - validate_slug, + int_list_validator, validate_comma_separated_integer_list, validate_email, + validate_integer, validate_ipv4_address, validate_ipv6_address, + validate_ipv46_address, validate_slug, ) from django.test import SimpleTestCase from django.test.utils import str_prefix @@ -120,12 +120,23 @@ TEST_DATA = [ (validate_ipv46_address, '12345::', ValidationError), (validate_comma_separated_integer_list, '1', None), + (validate_comma_separated_integer_list, '12', None), + (validate_comma_separated_integer_list, '1,2', None), (validate_comma_separated_integer_list, '1,2,3', None), - (validate_comma_separated_integer_list, '1,2,3,', None), + (validate_comma_separated_integer_list, '10,32', None), (validate_comma_separated_integer_list, '', ValidationError), + (validate_comma_separated_integer_list, 'a', ValidationError), (validate_comma_separated_integer_list, 'a,b,c', ValidationError), (validate_comma_separated_integer_list, '1, 2, 3', ValidationError), + (validate_comma_separated_integer_list, ',', ValidationError), + (validate_comma_separated_integer_list, '1,2,3,', ValidationError), + (validate_comma_separated_integer_list, '1,2,', ValidationError), + (validate_comma_separated_integer_list, ',1', ValidationError), + (validate_comma_separated_integer_list, '1,,2', ValidationError), + + (int_list_validator(sep='.'), '1.2.3', None), + (int_list_validator(sep='.'), '1,2,3', ValidationError), (MaxValueValidator(10), 10, None), (MaxValueValidator(10), -10, None), |