diff options
| author | Pradeek <jpradeek@gmail.com> | 2015-04-27 21:52:48 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-05-06 07:03:31 -0400 |
| commit | 6123e6134fba627a49ad379edfc20ae0f73bc9ac (patch) | |
| tree | 9ec30b9c8cc8f64a80c493aea75a8302c15cae7c /tests/validation | |
| parent | e7e39d32fd3aa53cf2861f083c24f9d1b38572d6 (diff) | |
Fixed #24708 -- Handled non-string values in GenericIPAddressField.to_python()
Diffstat (limited to 'tests/validation')
| -rw-r--r-- | tests/validation/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/validation/tests.py b/tests/validation/tests.py index 693d6b6c23..653a6b1c4c 100644 --- a/tests/validation/tests.py +++ b/tests/validation/tests.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django import forms from django.core.exceptions import NON_FIELD_ERRORS from django.test import TestCase +from django.utils.functional import lazy from . import ValidationTestCase from .models import ( @@ -129,6 +130,10 @@ class GenericIPAddressFieldTests(ValidationTestCase): def test_correct_generic_ip_passes(self): giptm = GenericIPAddressTestModel(generic_ip="1.2.3.4") self.assertIsNone(giptm.full_clean()) + giptm = GenericIPAddressTestModel(generic_ip=" 1.2.3.4 ") + self.assertIsNone(giptm.full_clean()) + giptm = GenericIPAddressTestModel(generic_ip="1.2.3.4\n") + self.assertIsNone(giptm.full_clean()) giptm = GenericIPAddressTestModel(generic_ip="2001::2") self.assertIsNone(giptm.full_clean()) @@ -137,6 +142,10 @@ class GenericIPAddressFieldTests(ValidationTestCase): self.assertFailsValidation(giptm.full_clean, ['generic_ip']) giptm = GenericIPAddressTestModel(generic_ip="1:2") self.assertFailsValidation(giptm.full_clean, ['generic_ip']) + giptm = GenericIPAddressTestModel(generic_ip=1) + self.assertFailsValidation(giptm.full_clean, ['generic_ip']) + giptm = GenericIPAddressTestModel(generic_ip=lazy(lambda: 1, int)) + self.assertFailsValidation(giptm.full_clean, ['generic_ip']) def test_correct_v4_ip_passes(self): giptm = GenericIPAddressTestModel(v4_ip="1.2.3.4") |
