diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ipaddress.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 20316f1..9e17ea0 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -466,6 +466,14 @@ class NetmaskTestMixin_v4(CommonTestMixin_v4): assertBadNetmask("1.1.1.1", "pudding") assertBadNetmask("1.1.1.1", "::") + def test_netmask_in_tuple_errors(self): + def assertBadNetmask(addr, netmask): + msg = "%r is not a valid netmask" % netmask + with self.assertNetmaskError(re.escape(msg)): + self.factory((addr, netmask)) + assertBadNetmask("1.1.1.1", -1) + assertBadNetmask("1.1.1.1", 33) + def test_pickle(self): self.pickle_test('192.0.2.0/27') self.pickle_test('192.0.2.0/31') # IPV4LENGTH - 1 @@ -588,6 +596,14 @@ class NetmaskTestMixin_v6(CommonTestMixin_v6): assertBadNetmask("::1", "pudding") assertBadNetmask("::", "::") + def test_netmask_in_tuple_errors(self): + def assertBadNetmask(addr, netmask): + msg = "%r is not a valid netmask" % netmask + with self.assertNetmaskError(re.escape(msg)): + self.factory((addr, netmask)) + assertBadNetmask("::1", -1) + assertBadNetmask("::1", 129) + def test_pickle(self): self.pickle_test('2001:db8::1000/124') self.pickle_test('2001:db8::1000/127') # IPV6LENGTH - 1 |