From d7a4228ebb0150e4c97a19077f3fac81d843e2c3 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Fri, 8 Jun 2018 09:29:46 -0300 Subject: python: futurize -f lib2to3.fixes.fix_has_key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change "dict.has_key(key)" to "key in dict" This is necessary for Python 3 compatibility. Done using: $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \ sort -u | grep -v README.sh4) $ futurize -w -f lib2to3.fixes.fix_has_key $py Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Eduardo Habkost Message-Id: <20180608122952.2009-5-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- tests/qemu-iotests/093 | 2 +- tests/qemu-iotests/096 | 4 ++-- tests/qemu-iotests/136 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093 index c3404a3171..68e344f8c1 100755 --- a/tests/qemu-iotests/093 +++ b/tests/qemu-iotests/093 @@ -237,7 +237,7 @@ class ThrottleTestGroupNames(iotests.QMPTestCase): if name: self.assertEqual(info["group"], name) else: - self.assertFalse(info.has_key('group')) + self.assertFalse('group' in info) return raise Exception("No group information found for '%s'" % device) diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096 index aeeb3753cf..a69439602d 100755 --- a/tests/qemu-iotests/096 +++ b/tests/qemu-iotests/096 @@ -53,9 +53,9 @@ class TestLiveSnapshot(iotests.QMPTestCase): self.assertEqual(r['iops'], self.iops) self.assertEqual(r['iops_size'], self.iops_size) else: - self.assertFalse(r.has_key('group')) + self.assertFalse('group' in r) self.assertEqual(r['iops'], 0) - self.assertFalse(r.has_key('iops_size')) + self.assertFalse('iops_size' in r) def testSnapshot(self): self.checkConfig('base') diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136 index 88b97ea7c6..a154d8ef9d 100755 --- a/tests/qemu-iotests/136 +++ b/tests/qemu-iotests/136 @@ -203,7 +203,7 @@ sector = "%d" if (self.accounted_ops(read = True, write = True, flush = True) != 0): self.assertLess(0, stats['idle_time_ns']) else: - self.assertFalse(stats.has_key('idle_time_ns')) + self.assertFalse('idle_time_ns' in stats) # This test does not alter these, so they must be all 0 self.assertEqual(0, stats['rd_merged']) -- cgit v1.2.3