Parcourir la source

Added tests for raising ValidationError instead of AddrFormatError

Sebastian Brandt il y a 10 ans
Parent
commit
0f81850bc3
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      netfields/tests.py

+ 5 - 1
netfields/tests.py

@@ -1,3 +1,4 @@
+from django.core.exceptions import ValidationError
 from netaddr import IPAddress, IPNetwork, EUI, AddrFormatError
 
 from django import VERSION
@@ -74,7 +75,7 @@ class BaseInetTestCase(BaseSqlTestCase):
         self.model(field=self.value1).save()
 
     def test_init_with_text_fails(self):
-        self.assertRaises(AddrFormatError, self.model, field='abc')
+        self.assertRaises(ValidationError, self.model, field='abc')
 
     def test_iexact_lookup(self):
         self.assertSqlEquals(self.qs.filter(field__iexact=self.value1),
@@ -387,6 +388,9 @@ class TestMacAddressField(BaseMacTestCase, TestCase):
     def test_save_nothing_fails(self):
         self.model().save()
 
+    def test_invalid_fails(self):
+        self.assertRaises(ValidationError, self.model(field='foobar').save)
+
 
 class MacAddressTestModelForm(ModelForm):
     class Meta: