summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ipaddress.py
diff options
context:
space:
mode:
authorHynek Schlawack <hs@ox.cx>2012-06-04 16:14:02 (GMT)
committerHynek Schlawack <hs@ox.cx>2012-06-04 16:14:02 (GMT)
commit454a74df23f2c39e34250361184dbff68b0d5b08 (patch)
treec2071d69a450aab12a2b45aa65252667be6d3cb9 /Lib/test/test_ipaddress.py
parentefce00c537ff611ee6d2521e36de3c92b1c10f5b (diff)
downloadcpython-454a74df23f2c39e34250361184dbff68b0d5b08.zip
cpython-454a74df23f2c39e34250361184dbff68b0d5b08.tar.gz
cpython-454a74df23f2c39e34250361184dbff68b0d5b08.tar.bz2
#14814: Remove dead code from ipaddress
_BaseNetwork contained (faulty) methods for creating string representations. I've fixed them and put them to use by eliminating identical overrides.
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r--Lib/test/test_ipaddress.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
index 5b7d013..17c32f2 100644
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -972,6 +972,22 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertTrue(self.ipv4_address in dummy)
self.assertTrue(ip2 in dummy)
+ def testIPv6NetworkHelpers(self):
+ net = self.ipv6_network
+ self.assertEqual('2001:658:22a:cafe::/64', net.with_prefixlen)
+ self.assertEqual('2001:658:22a:cafe::/ffff:ffff:ffff:ffff::',
+ net.with_netmask)
+ self.assertEqual('2001:658:22a:cafe::/::ffff:ffff:ffff:ffff',
+ net.with_hostmask)
+ self.assertEqual('2001:658:22a:cafe::/64', str(net))
+
+ def testIPv4NetworkHelpers(self):
+ net = self.ipv4_network
+ self.assertEqual('1.2.3.0/24', net.with_prefixlen)
+ self.assertEqual('1.2.3.0/255.255.255.0', net.with_netmask)
+ self.assertEqual('1.2.3.0/0.0.0.255', net.with_hostmask)
+ self.assertEqual('1.2.3.0/24', str(net))
+
def testCopyConstructor(self):
addr1 = ipaddress.ip_network('10.1.1.0/24')
addr2 = ipaddress.ip_network(addr1)