summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2018-06-11 10:55:42 -0400
committerPrashanth Pai <ppai@redhat.com>2018-06-13 15:23:04 +0000
commit8e63ca9bba888df0965f0beeed51a5336e6cb8cd (patch)
treeb0d9e2bc9aa4b24153fa2f92ae0a6a8bdef5f1b7 /contrib
parent81701e4d92ae7b1d97e5bc955703719f2e9e773a (diff)
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, and https://review.gluster.org/#/c/20207/ This patch changes uses of has_key() as suggested by the 2to3 utility. Note: Fedora packaging guidelines require explicit shebangs, so popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, zip, map, and raise have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Updates: #411 Change-Id: I79bda20f1583a0a1bb0320667498f4c137de93b3 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/ipaddr-py/ipaddr_test.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/contrib/ipaddr-py/ipaddr_test.py b/contrib/ipaddr-py/ipaddr_test.py
index c56ecb5c4b1..322bf98762e 100755
--- a/contrib/ipaddr-py/ipaddr_test.py
+++ b/contrib/ipaddr-py/ipaddr_test.py
@@ -1035,9 +1035,9 @@ class IpaddrUnitTest(unittest.TestCase):
def testNetworkElementCaching(self):
# V4 - make sure we're empty
- self.assertFalse(self.ipv4._cache.has_key('network'))
- self.assertFalse(self.ipv4._cache.has_key('broadcast'))
- self.assertFalse(self.ipv4._cache.has_key('hostmask'))
+ self.assertFalse('network' in self.ipv4._cache)
+ self.assertFalse('broadcast' in self.ipv4._cache)
+ self.assertFalse('hostmask' in self.ipv4._cache)
# V4 - populate and test
self.assertEqual(self.ipv4.network, ipaddr.IPv4Address('1.2.3.0'))
@@ -1045,14 +1045,14 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertEqual(self.ipv4.hostmask, ipaddr.IPv4Address('0.0.0.255'))
# V4 - check we're cached
- self.assertTrue(self.ipv4._cache.has_key('network'))
- self.assertTrue(self.ipv4._cache.has_key('broadcast'))
- self.assertTrue(self.ipv4._cache.has_key('hostmask'))
+ self.assertTrue('network' in self.ipv4._cache)
+ self.assertTrue('broadcast' in self.ipv4._cache)
+ self.assertTrue('hostmask' in self.ipv4._cache)
# V6 - make sure we're empty
- self.assertFalse(self.ipv6._cache.has_key('network'))
- self.assertFalse(self.ipv6._cache.has_key('broadcast'))
- self.assertFalse(self.ipv6._cache.has_key('hostmask'))
+ self.assertFalse('network' in self.ipv6._cache)
+ self.assertFalse('broadcast' in self.ipv6._cache)
+ self.assertFalse('hostmask' in self.ipv6._cache)
# V6 - populate and test
self.assertEqual(self.ipv6.network,
@@ -1063,9 +1063,9 @@ class IpaddrUnitTest(unittest.TestCase):
ipaddr.IPv6Address('::ffff:ffff:ffff:ffff'))
# V6 - check we're cached
- self.assertTrue(self.ipv6._cache.has_key('network'))
- self.assertTrue(self.ipv6._cache.has_key('broadcast'))
- self.assertTrue(self.ipv6._cache.has_key('hostmask'))
+ self.assertTrue('network' in self.ipv6._cache)
+ self.assertTrue('broadcast' in self.ipv6._cache)
+ self.assertTrue('hostmask' in self.ipv6._cache)
def testTeredo(self):
# stolen from wikipedia