All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility
@ 2017-12-19 17:34 Philippe Mathieu-Daudé
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for " Philippe Mathieu-Daudé
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster, Paolo Bonzini
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Nir Soffer, Peter Maydell,
	Janosch Frank, Ishani Chugh

Hi,

This is a very boring series.

I a later series I refactor the iotests.py class, however when the first version
of series [1] was posted I received comments that this class should no support
Python 3.

I didn't tested with very old CentOS release, but this should work with Python
versions >= 2.6.0a2.

Note: in today's IRC chat we suggest to drop Python 2 support for block iotests,
continuing to support it for common scripts used by the build system.

I'm not a Python expert, so I'll be very happy/relieved if someone is willing to
fix/continue/improve this series :)

Regards,

Phil.

[1]: http://lists.nongnu.org/archive/html/qemu-devel/2017-12/msg02339.html

Philippe Mathieu-Daudé (9):
  qemu.py: replace iteritems() by items() for python3 compatibility
  qmp.py: encode JSON unicode as byte strings for python3 compatibility
  iotests: replace print statement by print() function for python3
    compatibility
  iotests: use octal numbers for python3 compatibility
  iotests: replace xrange() by range() for python3 compatibility
  iotests: replace dict.has_key() by 'in' operator for python3
    compatibility
  iotests: replace lambda function by lambda expression for python3
    compatibility
  iotests: replace assertEquals() by assertEqual() for python3
    compatibility
  iotests.py: use io.StringIO with python3

 scripts/qemu.py               |  2 +-
 scripts/qmp/qmp.py            |  2 +-
 tests/qemu-iotests/041        |  6 +++---
 tests/qemu-iotests/044        | 14 +++++++-------
 tests/qemu-iotests/065        |  4 ++--
 tests/qemu-iotests/093        |  2 +-
 tests/qemu-iotests/096        |  4 ++--
 tests/qemu-iotests/118        | 28 ++++++++++++++--------------
 tests/qemu-iotests/136        |  2 +-
 tests/qemu-iotests/139        |  2 +-
 tests/qemu-iotests/149        |  3 ++-
 tests/qemu-iotests/163        |  2 +-
 tests/qemu-iotests/165        |  3 ++-
 tests/qemu-iotests/iotests.py | 14 +++++++++-----
 14 files changed, 47 insertions(+), 41 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20  9:58   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Cleber Rosa, Eduardo Habkost, Lukáš Doktor,
	Daniel P . Berrange, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Paolo Bonzini, Nir Soffer, Janosch Frank,
	Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 9bfdf6d37d..5e12ac7c8c 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -247,7 +247,7 @@ class QEMUMachine(object):
     def qmp(self, cmd, conv_keys=True, **args):
         '''Invoke a QMP command and return the response dict'''
         qmp_args = dict()
-        for key, value in args.iteritems():
+        for key, value in args.items():
             if conv_keys:
                 qmp_args[key.replace('_', '-')] = value
             else:
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:00   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Cleber Rosa, Eduardo Habkost, Lukáš Doktor,
	Daniel P . Berrange, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, Paolo Bonzini, Nir Soffer, Janosch Frank,
	Ishani Chugh

the socket API expects byte strings.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/qmp/qmp.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py
index 07c9632e9e..1080195e04 100644
--- a/scripts/qmp/qmp.py
+++ b/scripts/qmp/qmp.py
@@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object):
         """
         self.logger.debug(">>> %s", qmp_cmd)
         try:
-            self.__sock.sendall(json.dumps(qmp_cmd))
+            self.__sock.sendall(json.dumps(qmp_cmd).encode())
         except socket.error as err:
             if err[0] == errno.EPIPE:
                 return
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for " Philippe Mathieu-Daudé
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:03   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 4/9] iotests: use octal numbers " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/149        | 3 ++-
 tests/qemu-iotests/165        | 3 ++-
 tests/qemu-iotests/iotests.py | 5 +++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 223cd68ad5..d3ffa259db 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -20,6 +20,7 @@
 # Exercise the QEMU 'luks' block driver to validate interoperability
 # with the Linux dm-crypt + cryptsetup implementation
 
+from __future__ import print_function
 import subprocess
 import os
 import os.path
@@ -376,7 +377,7 @@ def test_once(config, qemu_img=False):
     finally:
         iotests.log("# Delete image")
         delete_image(config)
-        print
+        print()
 
 
 # Obviously we only work with the luks image format
diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
index a3932db3de..ab29066076 100755
--- a/tests/qemu-iotests/165
+++ b/tests/qemu-iotests/165
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import os
 import re
 import iotests
@@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
         log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
         log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
         if log:
-            print log
+            print(log)
 
         self.vm = self.mkVm()
         self.vm.launch()
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6f057904a9..85c9d2c211 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -16,6 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import errno
 import os
 import re
@@ -145,7 +146,7 @@ def filter_qmp_event(event):
 def log(msg, filters=[]):
     for flt in filters:
         msg = flt(msg)
-    print msg
+    print(msg)
 
 class Timeout:
     def __init__(self, seconds, errmsg = "Timeout"):
@@ -417,7 +418,7 @@ def notrun(reason):
     seq = os.path.basename(sys.argv[0])
 
     open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
-    print '%s not run: %s' % (seq, reason)
+    print("{} not run: {}".format(seq, reason))
     sys.exit(0)
 
 def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 4/9] iotests: use octal numbers for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:05   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() " Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/118 | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
index 8a9e838c90..3cf21218f0 100755
--- a/tests/qemu-iotests/118
+++ b/tests/qemu-iotests/118
@@ -417,14 +417,14 @@ class TestChangeReadOnly(ChangeBaseClass):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.chmod(old_img, 0666)
-        os.chmod(new_img, 0666)
+        os.chmod(old_img, 0o666)
+        os.chmod(new_img, 0o666)
         os.remove(old_img)
         os.remove(new_img)
 
     def test_ro_ro_retain(self):
-        os.chmod(old_img, 0444)
-        os.chmod(new_img, 0444)
+        os.chmod(old_img, 0o444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
         self.vm.launch()
 
@@ -443,7 +443,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_ro_rw_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
         self.vm.launch()
 
@@ -462,7 +462,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'floppy')
         self.vm.launch()
 
@@ -483,7 +483,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_ro_rw(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
         self.vm.launch()
 
@@ -503,7 +503,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'floppy')
         self.vm.launch()
 
@@ -542,7 +542,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'floppy')
         self.vm.launch()
 
@@ -562,7 +562,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_make_rw_ro_by_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
         self.vm.launch()
 
@@ -581,7 +581,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw_by_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'floppy')
         self.vm.launch()
 
@@ -600,7 +600,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_rw_ro_cycle(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'floppy')
         self.vm.launch()
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 4/9] iotests: use octal numbers " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:06   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/044 | 14 +++++++-------
 tests/qemu-iotests/163 |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
index 11ea0f4d35..1e96800176 100755
--- a/tests/qemu-iotests/044
+++ b/tests/qemu-iotests/044
@@ -52,23 +52,23 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
             # Write a refcount table
             fd.seek(off_reftable)
 
-            for i in xrange(0, h.refcount_table_clusters):
+            for i in range(0, h.refcount_table_clusters):
                 sector = ''.join(struct.pack('>Q',
                     off_refblock + i * 64 * 512 + j * 512)
-                    for j in xrange(0, 64))
+                    for j in range(0, 64))
                 fd.write(sector)
 
             # Write the refcount blocks
             assert(fd.tell() == off_refblock)
-            sector = ''.join(struct.pack('>H', 1) for j in xrange(0, 64 * 256))
-            for block in xrange(0, h.refcount_table_clusters):
+            sector = ''.join(struct.pack('>H', 1) for j in range(0, 64 * 256))
+            for block in range(0, h.refcount_table_clusters):
                 fd.write(sector)
 
             # Write the L1 table
             assert(fd.tell() == off_l1)
             assert(off_l2 + 512 * h.l1_size == off_data)
             table = ''.join(struct.pack('>Q', (1 << 63) | off_l2 + 512 * j)
-                for j in xrange(0, h.l1_size))
+                for j in range(0, h.l1_size))
             fd.write(table)
 
             # Write the L2 tables
@@ -79,14 +79,14 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
             off = off_data
             while remaining > 1024 * 512:
                 pytable = list((1 << 63) | off + 512 * j
-                    for j in xrange(0, 1024))
+                    for j in range(0, 1024))
                 table = struct.pack('>1024Q', *pytable)
                 fd.write(table)
                 remaining = remaining - 1024 * 512
                 off = off + 1024 * 512
 
             table = ''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
-                for j in xrange(0, remaining / 512))
+                for j in range(0, remaining / 512))
             fd.write(table)
 
 
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
index 403842354e..fb0d0257ec 100644
--- a/tests/qemu-iotests/163
+++ b/tests/qemu-iotests/163
@@ -41,7 +41,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
         div_roundup = lambda n, d: (n + d - 1) / d
 
         def split_by_n(data, n):
-            for x in xrange(0, len(data), n):
+            for x in range(0, len(data), n):
                 yield struct.unpack('>Q', data[x:x + n])[0] & l1_mask
 
         def check_l1_table(h, l1_data):
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:07   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/093 | 2 +-
 tests/qemu-iotests/096 | 4 ++--
 tests/qemu-iotests/136 | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index 5c36a5fb4d..28b1d021ca 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 100644
--- 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 100644
--- 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'])
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:08   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/065 | 4 ++--
 tests/qemu-iotests/139 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index 72aa9707c7..e95f7f817b 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -59,7 +59,7 @@ class TestQemuImgInfo(TestImageInfoSpecific):
                     :data.index('')]
         for field in data:
             self.assertTrue(re.match('^ {4}[^ ]', field) is not None)
-        data = map(lambda line: line.strip(), data)
+        data = [line.strip() for line in data]
         self.assertEqual(data, self.human_compare)
 
 class TestQMP(TestImageInfoSpecific):
@@ -80,7 +80,7 @@ class TestQMP(TestImageInfoSpecific):
 
     def test_qmp(self):
         result = self.vm.qmp('query-block')['return']
-        drive = filter(lambda drive: drive['device'] == 'drive0', result)[0]
+        drive = [drive for drive in result if drive['device'] == 'drive0'][0]
         data = drive['inserted']['image']['format-specific']
         self.assertEqual(data['type'], iotests.imgfmt)
         self.assertEqual(data['data'], self.compare)
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
index f8f02808a9..b54c816c16 100644
--- a/tests/qemu-iotests/139
+++ b/tests/qemu-iotests/139
@@ -51,7 +51,7 @@ class TestBlockdevDel(iotests.QMPTestCase):
     # Check whether a BlockDriverState exists
     def checkBlockDriverState(self, node, must_exist = True):
         result = self.vm.qmp('query-named-block-nodes')
-        nodes = filter(lambda x: x['node-name'] == node, result['return'])
+        nodes = [x for x in result['return'] if x['node-name'] == node]
         self.assertLessEqual(len(nodes), 1)
         self.assertEqual(must_exist, len(nodes) == 1)
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() for python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20 10:08   ` Daniel P. Berrange
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3 Philippe Mathieu-Daudé
  2017-12-19 21:54 ` [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Paolo Bonzini
  9 siblings, 1 reply; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/041        | 6 +++---
 tests/qemu-iotests/118        | 4 ++--
 tests/qemu-iotests/iotests.py | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index a860a31e9a..fa0f20af0e 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -457,7 +457,7 @@ new_state = "1"
         self.assert_qmp(result, 'return', {})
 
         event = self.vm.get_qmp_event(wait=True)
-        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
+        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'read')
         result = self.vm.qmp('query-block-jobs')
@@ -478,7 +478,7 @@ new_state = "1"
         self.assert_qmp(result, 'return', {})
 
         event = self.vm.get_qmp_event(wait=True)
-        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
+        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'read')
         result = self.vm.qmp('query-block-jobs')
@@ -609,7 +609,7 @@ new_state = "1"
         self.assert_qmp(result, 'return', {})
 
         event = self.vm.get_qmp_event(wait=True)
-        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
+        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'write')
         result = self.vm.qmp('query-block-jobs')
diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
index 3cf21218f0..8158b4bd25 100755
--- a/tests/qemu-iotests/118
+++ b/tests/qemu-iotests/118
@@ -295,7 +295,7 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
         result = self.vm.qmp('blockdev-close-tray', device='drive0')
         # Should be a no-op
         self.assert_qmp(result, 'return', {})
-        self.assertEquals(self.vm.get_qmp_events(wait=False), [])
+        self.assertEqual(self.vm.get_qmp_events(wait=False), [])
 
     def test_remove_on_closed(self):
         if not self.has_real_tray:
@@ -476,7 +476,7 @@ class TestChangeReadOnly(ChangeBaseClass):
                                                        read_only_mode='retain')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
-        self.assertEquals(self.vm.get_qmp_events(wait=False), [])
+        self.assertEqual(self.vm.get_qmp_events(wait=False), [])
 
         result = self.vm.qmp('query-block')
         self.assert_qmp(result, 'return[0]/inserted/ro', False)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 85c9d2c211..4c515d2e6c 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -385,7 +385,7 @@ class QMPTestCase(unittest.TestCase):
     def wait_ready_and_cancel(self, drive='drive0'):
         self.wait_ready(drive=drive)
         event = self.cancel_and_wait(drive=drive)
-        self.assertEquals(event['event'], 'BLOCK_JOB_COMPLETED')
+        self.assertEqual(event['event'], 'BLOCK_JOB_COMPLETED')
         self.assert_qmp(event, 'data/type', 'mirror')
         self.assert_qmp(event, 'data/offset', event['data']['len'])
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() " Philippe Mathieu-Daudé
@ 2017-12-19 17:34 ` Philippe Mathieu-Daudé
  2017-12-20  6:48   ` Janosch Frank
  2017-12-20 10:10   ` Daniel P. Berrange
  2017-12-19 21:54 ` [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Paolo Bonzini
  9 siblings, 2 replies; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-12-19 17:34 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: Philippe Mathieu-Daudé,
	qemu-devel, qemu-block, John Snow, Paolo Bonzini, Nir Soffer,
	Janosch Frank, Ishani Chugh

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/qemu-iotests/iotests.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 4c515d2e6c..0e1b8ab6e6 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -459,13 +459,16 @@ def main(supported_fmts=[], supported_oses=['linux']):
 
     # We need to filter out the time taken from the output so that qemu-iotest
     # can reliably diff the results against master output.
-    import StringIO
     if debug:
         output = sys.stdout
         verbosity = 2
         sys.argv.remove('-d')
     else:
-        output = StringIO.StringIO()
+        try:
+            from StringIO import StringIO
+        except ImportError:
+            from io import StringIO
+        output = StringIO()
 
     logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility
  2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3 Philippe Mathieu-Daudé
@ 2017-12-19 21:54 ` Paolo Bonzini
  9 siblings, 0 replies; 21+ messages in thread
From: Paolo Bonzini @ 2017-12-19 21:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: qemu-devel, qemu-block, John Snow, Nir Soffer, Peter Maydell,
	Janosch Frank, Ishani Chugh

On 19/12/2017 18:34, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This is a very boring series.
> 
> I a later series I refactor the iotests.py class, however when the first version
> of series [1] was posted I received comments that this class should no support
> Python 3.
> 
> I didn't tested with very old CentOS release, but this should work with Python
> versions >= 2.6.0a2.

Thanks, this is useful.  However, it'd be much easier if the commit
messages showed the actual error message that is fixed, or an example.

Paolo

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3 Philippe Mathieu-Daudé
@ 2017-12-20  6:48   ` Janosch Frank
  2017-12-20 10:10   ` Daniel P. Berrange
  1 sibling, 0 replies; 21+ messages in thread
From: Janosch Frank @ 2017-12-20  6:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Daniel P . Berrange, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster
  Cc: qemu-block, Nir Soffer, Ishani Chugh, qemu-devel, Paolo Bonzini,
	John Snow

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On 19.12.2017 18:34, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/iotests.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 4c515d2e6c..0e1b8ab6e6 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -459,13 +459,16 @@ def main(supported_fmts=[], supported_oses=['linux']):
> 
>      # We need to filter out the time taken from the output so that qemu-iotest
>      # can reliably diff the results against master output.
> -    import StringIO
>      if debug:
>          output = sys.stdout
>          verbosity = 2
>          sys.argv.remove('-d')
>      else:
> -        output = StringIO.StringIO()
> +        try:
> +            from StringIO import StringIO
> +        except ImportError:
> +            from io import StringIO
> +        output = StringIO()

*Please* make a commit message that mentions that StringIO was moved
into the io package for py3. It took me way too long to make any sense
of this change until I read the except statement.
Maybe also add a comment.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for " Philippe Mathieu-Daudé
@ 2017-12-20  9:58   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20  9:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Cleber Rosa, Eduardo Habkost, Lukáš Doktor, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster, qemu-devel,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:17PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/qemu.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings " Philippe Mathieu-Daudé
@ 2017-12-20 10:00   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Cleber Rosa, Eduardo Habkost, Lukáš Doktor, Eric Blake,
	Stefan Hajnoczi, Fam Zheng, Markus Armbruster, qemu-devel,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:18PM -0300, Philippe Mathieu-Daudé wrote:
> the socket API expects byte strings.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/qmp/qmp.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py
> index 07c9632e9e..1080195e04 100644
> --- a/scripts/qmp/qmp.py
> +++ b/scripts/qmp/qmp.py
> @@ -166,7 +166,7 @@ class QEMUMonitorProtocol(object):
>          """
>          self.logger.debug(">>> %s", qmp_cmd)
>          try:
> -            self.__sock.sendall(json.dumps(qmp_cmd))
> +            self.__sock.sendall(json.dumps(qmp_cmd).encode())
>          except socket.error as err:
>              if err[0] == errno.EPIPE:
>                  return
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function " Philippe Mathieu-Daudé
@ 2017-12-20 10:03   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:19PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/149        | 3 ++-
>  tests/qemu-iotests/165        | 3 ++-
>  tests/qemu-iotests/iotests.py | 5 +++--
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
> index 223cd68ad5..d3ffa259db 100755
> --- a/tests/qemu-iotests/149
> +++ b/tests/qemu-iotests/149
> @@ -20,6 +20,7 @@
>  # Exercise the QEMU 'luks' block driver to validate interoperability
>  # with the Linux dm-crypt + cryptsetup implementation
>  
> +from __future__ import print_function
>  import subprocess
>  import os
>  import os.path
> @@ -376,7 +377,7 @@ def test_once(config, qemu_img=False):
>      finally:
>          iotests.log("# Delete image")
>          delete_image(config)
> -        print
> +        print()
>  
>  
>  # Obviously we only work with the luks image format
> diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165
> index a3932db3de..ab29066076 100755
> --- a/tests/qemu-iotests/165
> +++ b/tests/qemu-iotests/165
> @@ -18,6 +18,7 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  #
>  
> +from __future__ import print_function
>  import os
>  import re
>  import iotests
> @@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
>          log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
>          log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
>          if log:
> -            print log
> +            print(log)
>  
>          self.vm = self.mkVm()
>          self.vm.launch()
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 6f057904a9..85c9d2c211 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -16,6 +16,7 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  #
>  
> +from __future__ import print_function
>  import errno
>  import os
>  import re
> @@ -145,7 +146,7 @@ def filter_qmp_event(event):
>  def log(msg, filters=[]):
>      for flt in filters:
>          msg = flt(msg)
> -    print msg
> +    print(msg)
>  
>  class Timeout:
>      def __init__(self, seconds, errmsg = "Timeout"):
> @@ -417,7 +418,7 @@ def notrun(reason):
>      seq = os.path.basename(sys.argv[0])
>  
>      open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
> -    print '%s not run: %s' % (seq, reason)
> +    print("{} not run: {}".format(seq, reason))

I don't see the benefit in changing '%s' to '{}' and '%s' to '.format'.
The original code is the idiomatic python IME.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 4/9] iotests: use octal numbers for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 4/9] iotests: use octal numbers " Philippe Mathieu-Daudé
@ 2017-12-20 10:05   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:20PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/118 | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
> index 8a9e838c90..3cf21218f0 100755
> --- a/tests/qemu-iotests/118
> +++ b/tests/qemu-iotests/118
> @@ -417,14 +417,14 @@ class TestChangeReadOnly(ChangeBaseClass):
>  
>      def tearDown(self):
>          self.vm.shutdown()
> -        os.chmod(old_img, 0666)
> -        os.chmod(new_img, 0666)
> +        os.chmod(old_img, 0o666)
> +        os.chmod(new_img, 0o666)
>          os.remove(old_img)
>          os.remove(new_img)
>  
>      def test_ro_ro_retain(self):
> -        os.chmod(old_img, 0444)
> -        os.chmod(new_img, 0444)
> +        os.chmod(old_img, 0o444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
>          self.vm.launch()
>  
> @@ -443,7 +443,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
>  
>      def test_ro_rw_retain(self):
> -        os.chmod(old_img, 0444)
> +        os.chmod(old_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
>          self.vm.launch()
>  
> @@ -462,7 +462,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
>  
>      def test_rw_ro_retain(self):
> -        os.chmod(new_img, 0444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk', 'floppy')
>          self.vm.launch()
>  
> @@ -483,7 +483,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
>  
>      def test_ro_rw(self):
> -        os.chmod(old_img, 0444)
> +        os.chmod(old_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
>          self.vm.launch()
>  
> @@ -503,7 +503,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
>  
>      def test_rw_ro(self):
> -        os.chmod(new_img, 0444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk', 'floppy')
>          self.vm.launch()
>  
> @@ -542,7 +542,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
>  
>      def test_make_ro_rw(self):
> -        os.chmod(new_img, 0444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk', 'floppy')
>          self.vm.launch()
>  
> @@ -562,7 +562,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
>  
>      def test_make_rw_ro_by_retain(self):
> -        os.chmod(old_img, 0444)
> +        os.chmod(old_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy')
>          self.vm.launch()
>  
> @@ -581,7 +581,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
>  
>      def test_make_ro_rw_by_retain(self):
> -        os.chmod(new_img, 0444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk', 'floppy')
>          self.vm.launch()
>  
> @@ -600,7 +600,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>          self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
>  
>      def test_rw_ro_cycle(self):
> -        os.chmod(new_img, 0444)
> +        os.chmod(new_img, 0o444)
>          self.vm.add_drive(old_img, 'media=disk', 'floppy')
>          self.vm.launch()
>  
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() " Philippe Mathieu-Daudé
@ 2017-12-20 10:06   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:21PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/044 | 14 +++++++-------
>  tests/qemu-iotests/163 |  2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
> index 11ea0f4d35..1e96800176 100755
> --- a/tests/qemu-iotests/044
> +++ b/tests/qemu-iotests/044
> @@ -52,23 +52,23 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
>              # Write a refcount table
>              fd.seek(off_reftable)
>  
> -            for i in xrange(0, h.refcount_table_clusters):
> +            for i in range(0, h.refcount_table_clusters):
>                  sector = ''.join(struct.pack('>Q',
>                      off_refblock + i * 64 * 512 + j * 512)
> -                    for j in xrange(0, 64))
> +                    for j in range(0, 64))
>                  fd.write(sector)
>  
>              # Write the refcount blocks
>              assert(fd.tell() == off_refblock)
> -            sector = ''.join(struct.pack('>H', 1) for j in xrange(0, 64 * 256))
> -            for block in xrange(0, h.refcount_table_clusters):
> +            sector = ''.join(struct.pack('>H', 1) for j in range(0, 64 * 256))
> +            for block in range(0, h.refcount_table_clusters):
>                  fd.write(sector)
>  
>              # Write the L1 table
>              assert(fd.tell() == off_l1)
>              assert(off_l2 + 512 * h.l1_size == off_data)
>              table = ''.join(struct.pack('>Q', (1 << 63) | off_l2 + 512 * j)
> -                for j in xrange(0, h.l1_size))
> +                for j in range(0, h.l1_size))
>              fd.write(table)
>  
>              # Write the L2 tables
> @@ -79,14 +79,14 @@ class TestRefcountTableGrowth(iotests.QMPTestCase):
>              off = off_data
>              while remaining > 1024 * 512:
>                  pytable = list((1 << 63) | off + 512 * j
> -                    for j in xrange(0, 1024))
> +                    for j in range(0, 1024))
>                  table = struct.pack('>1024Q', *pytable)
>                  fd.write(table)
>                  remaining = remaining - 1024 * 512
>                  off = off + 1024 * 512
>  
>              table = ''.join(struct.pack('>Q', (1 << 63) | off + 512 * j)
> -                for j in xrange(0, remaining / 512))
> +                for j in range(0, remaining / 512))
>              fd.write(table)
>  
>  
> diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
> index 403842354e..fb0d0257ec 100644
> --- a/tests/qemu-iotests/163
> +++ b/tests/qemu-iotests/163
> @@ -41,7 +41,7 @@ class ShrinkBaseClass(iotests.QMPTestCase):
>          div_roundup = lambda n, d: (n + d - 1) / d
>  
>          def split_by_n(data, n):
> -            for x in xrange(0, len(data), n):
> +            for x in range(0, len(data), n):
>                  yield struct.unpack('>Q', data[x:x + n])[0] & l1_mask
>  
>          def check_l1_table(h, l1_data):
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator " Philippe Mathieu-Daudé
@ 2017-12-20 10:07   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:22PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/093 | 2 +-
>  tests/qemu-iotests/096 | 4 ++--
>  tests/qemu-iotests/136 | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
> index 5c36a5fb4d..28b1d021ca 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 100644
> --- 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 100644
> --- 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'])
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression " Philippe Mathieu-Daudé
@ 2017-12-20 10:08   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank

On Tue, Dec 19, 2017 at 02:34:23PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/065 | 4 ++--
>  tests/qemu-iotests/139 | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
> index 72aa9707c7..e95f7f817b 100755
> --- a/tests/qemu-iotests/065
> +++ b/tests/qemu-iotests/065
> @@ -59,7 +59,7 @@ class TestQemuImgInfo(TestImageInfoSpecific):
>                      :data.index('')]
>          for field in data:
>              self.assertTrue(re.match('^ {4}[^ ]', field) is not None)
> -        data = map(lambda line: line.strip(), data)
> +        data = [line.strip() for line in data]
>          self.assertEqual(data, self.human_compare)
>  
>  class TestQMP(TestImageInfoSpecific):
> @@ -80,7 +80,7 @@ class TestQMP(TestImageInfoSpecific):
>  
>      def test_qmp(self):
>          result = self.vm.qmp('query-block')['return']
> -        drive = filter(lambda drive: drive['device'] == 'drive0', result)[0]
> +        drive = [drive for drive in result if drive['device'] == 'drive0'][0]
>          data = drive['inserted']['image']['format-specific']
>          self.assertEqual(data['type'], iotests.imgfmt)
>          self.assertEqual(data['data'], self.compare)
> diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
> index f8f02808a9..b54c816c16 100644
> --- a/tests/qemu-iotests/139
> +++ b/tests/qemu-iotests/139
> @@ -51,7 +51,7 @@ class TestBlockdevDel(iotests.QMPTestCase):
>      # Check whether a BlockDriverState exists
>      def checkBlockDriverState(self, node, must_exist = True):
>          result = self.vm.qmp('query-named-block-nodes')
> -        nodes = filter(lambda x: x['node-name'] == node, result['return'])
> +        nodes = [x for x in result['return'] if x['node-name'] == node]
>          self.assertLessEqual(len(nodes), 1)
>          self.assertEqual(must_exist, len(nodes) == 1)
>  
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() for python3 compatibility
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() " Philippe Mathieu-Daudé
@ 2017-12-20 10:08   ` Daniel P. Berrange
  0 siblings, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:24PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/041        | 6 +++---
>  tests/qemu-iotests/118        | 4 ++--
>  tests/qemu-iotests/iotests.py | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
> index a860a31e9a..fa0f20af0e 100755
> --- a/tests/qemu-iotests/041
> +++ b/tests/qemu-iotests/041
> @@ -457,7 +457,7 @@ new_state = "1"
>          self.assert_qmp(result, 'return', {})
>  
>          event = self.vm.get_qmp_event(wait=True)
> -        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
> +        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
>          self.assert_qmp(event, 'data/device', 'drive0')
>          self.assert_qmp(event, 'data/operation', 'read')
>          result = self.vm.qmp('query-block-jobs')
> @@ -478,7 +478,7 @@ new_state = "1"
>          self.assert_qmp(result, 'return', {})
>  
>          event = self.vm.get_qmp_event(wait=True)
> -        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
> +        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
>          self.assert_qmp(event, 'data/device', 'drive0')
>          self.assert_qmp(event, 'data/operation', 'read')
>          result = self.vm.qmp('query-block-jobs')
> @@ -609,7 +609,7 @@ new_state = "1"
>          self.assert_qmp(result, 'return', {})
>  
>          event = self.vm.get_qmp_event(wait=True)
> -        self.assertEquals(event['event'], 'BLOCK_JOB_ERROR')
> +        self.assertEqual(event['event'], 'BLOCK_JOB_ERROR')
>          self.assert_qmp(event, 'data/device', 'drive0')
>          self.assert_qmp(event, 'data/operation', 'write')
>          result = self.vm.qmp('query-block-jobs')
> diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118
> index 3cf21218f0..8158b4bd25 100755
> --- a/tests/qemu-iotests/118
> +++ b/tests/qemu-iotests/118
> @@ -295,7 +295,7 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
>          result = self.vm.qmp('blockdev-close-tray', device='drive0')
>          # Should be a no-op
>          self.assert_qmp(result, 'return', {})
> -        self.assertEquals(self.vm.get_qmp_events(wait=False), [])
> +        self.assertEqual(self.vm.get_qmp_events(wait=False), [])
>  
>      def test_remove_on_closed(self):
>          if not self.has_real_tray:
> @@ -476,7 +476,7 @@ class TestChangeReadOnly(ChangeBaseClass):
>                                                         read_only_mode='retain')
>          self.assert_qmp(result, 'error/class', 'GenericError')
>  
> -        self.assertEquals(self.vm.get_qmp_events(wait=False), [])
> +        self.assertEqual(self.vm.get_qmp_events(wait=False), [])
>  
>          result = self.vm.qmp('query-block')
>          self.assert_qmp(result, 'return[0]/inserted/ro', False)
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 85c9d2c211..4c515d2e6c 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -385,7 +385,7 @@ class QMPTestCase(unittest.TestCase):
>      def wait_ready_and_cancel(self, drive='drive0'):
>          self.wait_ready(drive=drive)
>          event = self.cancel_and_wait(drive=drive)
> -        self.assertEquals(event['event'], 'BLOCK_JOB_COMPLETED')
> +        self.assertEqual(event['event'], 'BLOCK_JOB_COMPLETED')
>          self.assert_qmp(event, 'data/type', 'mirror')
>          self.assert_qmp(event, 'data/offset', event['data']['len'])
>  
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3
  2017-12-19 17:34 ` [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3 Philippe Mathieu-Daudé
  2017-12-20  6:48   ` Janosch Frank
@ 2017-12-20 10:10   ` Daniel P. Berrange
  1 sibling, 0 replies; 21+ messages in thread
From: Daniel P. Berrange @ 2017-12-20 10:10 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Kevin Wolf, Max Reitz, Cleber Rosa, Eduardo Habkost,
	Lukáš Doktor, Eric Blake, Stefan Hajnoczi, Fam Zheng,
	Markus Armbruster, qemu-devel, qemu-block, John Snow,
	Paolo Bonzini, Nir Soffer, Janosch Frank, Ishani Chugh

On Tue, Dec 19, 2017 at 02:34:25PM -0300, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/qemu-iotests/iotests.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 4c515d2e6c..0e1b8ab6e6 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -459,13 +459,16 @@ def main(supported_fmts=[], supported_oses=['linux']):
>  
>      # We need to filter out the time taken from the output so that qemu-iotest
>      # can reliably diff the results against master output.
> -    import StringIO
>      if debug:
>          output = sys.stdout
>          verbosity = 2
>          sys.argv.remove('-d')
>      else:
> -        output = StringIO.StringIO()
> +        try:
> +            from StringIO import StringIO
> +        except ImportError:
> +            from io import StringIO
> +        output = StringIO()

If it was nit-picking I'd put the py3 'io' import first and the py2
'StringIO' as the fallback, but doesn't honestly matter

>  
>      logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
>  
> -- 
> 2.15.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-12-20 10:10 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 17:34 [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Philippe Mathieu-Daudé
2017-12-19 17:34 ` [Qemu-devel] [PATCH 1/9] qemu.py: replace iteritems() by items() for " Philippe Mathieu-Daudé
2017-12-20  9:58   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 2/9] qmp.py: encode JSON unicode as byte strings " Philippe Mathieu-Daudé
2017-12-20 10:00   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 3/9] iotests: replace print statement by print() function " Philippe Mathieu-Daudé
2017-12-20 10:03   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 4/9] iotests: use octal numbers " Philippe Mathieu-Daudé
2017-12-20 10:05   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 5/9] iotests: replace xrange() by range() " Philippe Mathieu-Daudé
2017-12-20 10:06   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 6/9] iotests: replace dict.has_key() by 'in' operator " Philippe Mathieu-Daudé
2017-12-20 10:07   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 7/9] iotests: replace lambda function by lambda expression " Philippe Mathieu-Daudé
2017-12-20 10:08   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 8/9] iotests: replace assertEquals() by assertEqual() " Philippe Mathieu-Daudé
2017-12-20 10:08   ` Daniel P. Berrange
2017-12-19 17:34 ` [Qemu-devel] [PATCH 9/9] iotests.py: use io.StringIO with python3 Philippe Mathieu-Daudé
2017-12-20  6:48   ` Janosch Frank
2017-12-20 10:10   ` Daniel P. Berrange
2017-12-19 21:54 ` [Qemu-devel] [PATCH 0/9] iotests: python3 compatibility Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.