diff options
author | Sandro Tosi <sandro.tosi@gmail.com> | 2012-05-23 20:26:55 (GMT) |
---|---|---|
committer | Sandro Tosi <sandro.tosi@gmail.com> | 2012-05-23 20:26:55 (GMT) |
commit | 876ecad9f513f69a7710cea88ce35df927d7ddba (patch) | |
tree | d5c54f1d25357c4133d9280b02225a7ad4c283cd /Lib/test/test_ipaddress.py | |
parent | 3bc37f2360d634b12190590aeb5de935bece5b78 (diff) | |
download | cpython-876ecad9f513f69a7710cea88ce35df927d7ddba.zip cpython-876ecad9f513f69a7710cea88ce35df927d7ddba.tar.gz cpython-876ecad9f513f69a7710cea88ce35df927d7ddba.tar.bz2 |
Issue #14814: improve docstrings and arguments value handling, as per Terry J. Reedy's comments
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() |