diff options
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r-- | Lib/test/test_ipaddress.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 146f9a3..6bf5174 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -780,6 +780,12 @@ class IpaddrUnitTest(unittest.TestCase): self.assertEqual(self.ipv4_address.version, 4) self.assertEqual(self.ipv6_address.version, 6) + with self.assertRaises(ValueError): + ipaddress.ip_address('1', version=[]) + + with self.assertRaises(ValueError): + ipaddress.ip_address('1', version=5) + def testMaxPrefixLength(self): self.assertEqual(self.ipv4_interface.max_prefixlen, 32) self.assertEqual(self.ipv6_interface.max_prefixlen, 128) @@ -1048,6 +1054,11 @@ class IpaddrUnitTest(unittest.TestCase): self.assertEqual(ipaddress.ip_network(1).version, 4) self.assertEqual(ipaddress.ip_network(1, version=6).version, 6) + with self.assertRaises(ValueError): + ipaddress.ip_network(1, version='l') + with self.assertRaises(ValueError): + ipaddress.ip_network(1, version=3) + def testWithStar(self): self.assertEqual(str(self.ipv4_interface.with_prefixlen), "1.2.3.4/24") self.assertEqual(str(self.ipv4_interface.with_netmask), @@ -1137,6 +1148,13 @@ class IpaddrUnitTest(unittest.TestCase): sixtofouraddr.sixtofour) self.assertFalse(bad_addr.sixtofour) + def testIpInterfaceVersion(self): + with self.assertRaises(ValueError): + ipaddress.ip_interface(1, version=123) + + with self.assertRaises(ValueError): + ipaddress.ip_interface(1, version='') + if __name__ == '__main__': unittest.main() |