All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] python: Use io.StringIO
@ 2018-10-10 21:31 Philippe Mathieu-Daudé
  2018-10-10 22:22 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
  2018-10-11 11:33 ` [Qemu-devel] " Kevin Wolf
  0 siblings, 2 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-10 21:31 UTC (permalink / raw)
  To: Fam Zheng, Kevin Wolf, Max Reitz, Eduardo Habkost,
	Alex Bennée, Daniel P . Berrange
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-block

Both Python 2.7 and 3 support the same io.StringIO to
handle unicode strings.

Use the common form to use indistinctly Python 2.7 or 3.

http://python-future.org/compatible_idioms.html#stringio

This fixes running tests on the Fedora Docker image,
which uses Python3 since 356dc290f:

  $ make docker-test-block@fedora
  [...]
  045         [failed, exit status 1] - output mismatch (see 045.out.bad)
  --- /tmp/qemu-test/src/tests/qemu-iotests/045.out       2018-07-17 16:56:18.000000000 +0000
  +++ /tmp/qemu-test/build/tests/qemu-iotests/045.out.bad 2018-07-17 17:19:22.448409007 +0000
  @@ -1,5 +1,6 @@
  -...........
  -----------------------------------------------------------------------
  -Ran 11 tests
  -
  -OK
  +Traceback (most recent call last):
  +  File "045", line 178, in <module>
  +    iotests.main(supported_fmts=['raw'])
  +  File "/tmp/qemu-test/src/tests/qemu-iotests/iotests.py", line 682, in main
  +    import StringIO
  +ModuleNotFoundError: No module named 'StringIO'
  132         [failed, exit status 1] - output mismatch (see 132.out.bad)
  152         [failed, exit status 1] - output mismatch (see 152.out.bad)

  Failures: 045 132 152

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

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 4e67fbbe96..cd9be1bd9c 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -679,13 +679,13 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
 
     # 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
+    from io import StringIO
     if debug:
         output = sys.stdout
         verbosity = 2
         sys.argv.remove('-d')
     else:
-        output = StringIO.StringIO()
+        output = StringIO()
 
     logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
 
-- 
2.19.1

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

end of thread, other threads:[~2018-10-11 17:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 21:31 [Qemu-devel] [PATCH v3] python: Use io.StringIO Philippe Mathieu-Daudé
2018-10-10 22:22 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-10-11 11:33 ` [Qemu-devel] " Kevin Wolf
2018-10-11 12:43   ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-10-11 14:01     ` Markus Armbruster
2018-10-11 14:44       ` Philippe Mathieu-Daudé
2018-10-11 14:56       ` Kevin Wolf
2018-10-11 17:02         ` Eduardo Habkost

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.