diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-08 14:39:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-08 14:39:51 (GMT) |
commit | 99b1f2b3bba6cd7c2f9c78183e3275436ed0b363 (patch) | |
tree | 3dd861ea05b20b1e21e99c81d7400ac416c65912 /Lib/test/test_ipaddress.py | |
parent | c03027054d1ca43b6ef2d815107c4e8d9dfdd8c1 (diff) | |
parent | 7c389e2404b97b5e48c02e2735229eef30e3f1cf (diff) | |
download | cpython-99b1f2b3bba6cd7c2f9c78183e3275436ed0b363.zip cpython-99b1f2b3bba6cd7c2f9c78183e3275436ed0b363.tar.gz cpython-99b1f2b3bba6cd7c2f9c78183e3275436ed0b363.tar.bz2 |
Issue #20553. Use specific asserts in ipaddress tests.
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r-- | Lib/test/test_ipaddress.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 019f35a..f2947b9 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -921,13 +921,13 @@ class IpaddrUnitTest(unittest.TestCase): 36893488147419103232) def testContains(self): - self.assertTrue(ipaddress.IPv4Interface('1.2.3.128/25') in - self.ipv4_network) - self.assertFalse(ipaddress.IPv4Interface('1.2.4.1/24') in + self.assertIn(ipaddress.IPv4Interface('1.2.3.128/25'), + self.ipv4_network) + self.assertNotIn(ipaddress.IPv4Interface('1.2.4.1/24'), self.ipv4_network) # We can test addresses and string as well. addr1 = ipaddress.IPv4Address('1.2.3.37') - self.assertTrue(addr1 in self.ipv4_network) + self.assertIn(addr1, self.ipv4_network) # issue 61, bad network comparison on like-ip'd network objects # with identical broadcast addresses. self.assertFalse(ipaddress.IPv4Network('1.1.0.0/16').__contains__( @@ -1512,8 +1512,8 @@ class IpaddrUnitTest(unittest.TestCase): dummy[self.ipv6_address] = None dummy[ip1] = None dummy[ip2] = None - self.assertTrue(self.ipv4_address in dummy) - self.assertTrue(ip2 in dummy) + self.assertIn(self.ipv4_address, dummy) + self.assertIn(ip2, dummy) def testIPBases(self): net = self.ipv4_network @@ -1620,9 +1620,9 @@ class IpaddrUnitTest(unittest.TestCase): def testNetworkElementCaching(self): # V4 - make sure we're empty - self.assertFalse('network_address' in self.ipv4_network._cache) - self.assertFalse('broadcast_address' in self.ipv4_network._cache) - self.assertFalse('hostmask' in self.ipv4_network._cache) + self.assertNotIn('network_address', self.ipv4_network._cache) + self.assertNotIn('broadcast_address', self.ipv4_network._cache) + self.assertNotIn('hostmask', self.ipv4_network._cache) # V4 - populate and test self.assertEqual(self.ipv4_network.network_address, @@ -1633,12 +1633,12 @@ class IpaddrUnitTest(unittest.TestCase): ipaddress.IPv4Address('0.0.0.255')) # V4 - check we're cached - self.assertTrue('broadcast_address' in self.ipv4_network._cache) - self.assertTrue('hostmask' in self.ipv4_network._cache) + self.assertIn('broadcast_address', self.ipv4_network._cache) + self.assertIn('hostmask', self.ipv4_network._cache) # V6 - make sure we're empty - self.assertFalse('broadcast_address' in self.ipv6_network._cache) - self.assertFalse('hostmask' in self.ipv6_network._cache) + self.assertNotIn('broadcast_address', self.ipv6_network._cache) + self.assertNotIn('hostmask', self.ipv6_network._cache) # V6 - populate and test self.assertEqual(self.ipv6_network.network_address, @@ -1658,11 +1658,10 @@ class IpaddrUnitTest(unittest.TestCase): ipaddress.IPv6Address('::ffff:ffff:ffff:ffff')) # V6 - check we're cached - self.assertTrue('broadcast_address' in self.ipv6_network._cache) - self.assertTrue('hostmask' in self.ipv6_network._cache) - self.assertTrue( - 'broadcast_address' in self.ipv6_interface.network._cache) - self.assertTrue('hostmask' in self.ipv6_interface.network._cache) + self.assertIn('broadcast_address', self.ipv6_network._cache) + self.assertIn('hostmask', self.ipv6_network._cache) + self.assertIn('broadcast_address', self.ipv6_interface.network._cache) + self.assertIn('hostmask', self.ipv6_interface.network._cache) def testTeredo(self): # stolen from wikipedia |