1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34818 -- Prevented GenericIPAddressField from mutating error messages.

Co-authored-by: Parth Verma <parth.verma@gmail.com>
This commit is contained in:
Parth Verma
2023-11-23 20:46:17 -08:00
committed by GitHub
parent a8adb6aa6c
commit eabfa2d0e3
5 changed files with 33 additions and 15 deletions

View File

@@ -206,3 +206,17 @@ class GenericIPAddressFieldTests(ValidationAssertions, TestCase):
self.assertIsNone(giptm.full_clean())
giptm = GenericIPAddressTestModel(generic_ip=None)
self.assertIsNone(giptm.full_clean())
def test_multiple_invalid_ip_raises_error(self):
giptm = GenericIPAddressTestModel(
v6_ip="1.2.3.4", v4_ip="::ffff:10.10.10.10", generic_ip="fsad"
)
self.assertFieldFailsValidationWithMessage(
giptm.full_clean, "v6_ip", ["Enter a valid IPv6 address."]
)
self.assertFieldFailsValidationWithMessage(
giptm.full_clean, "v4_ip", ["Enter a valid IPv4 address."]
)
self.assertFieldFailsValidationWithMessage(
giptm.full_clean, "generic_ip", ["Enter a valid IPv4 or IPv6 address."]
)