From: Thomas Huth <thuth@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, philmd@redhat.com, jsnow@redhat.com,
ehabkost@redhat.com, mreitz@redhat.com
Subject: Re: [PATCH v2 2/2] iotests: Remove Python 2 compatibility code
Date: Thu, 19 Sep 2019 18:42:56 +0200 [thread overview]
Message-ID: <09a9cf74-a6f0-bce7-ceac-052cd8ea7ae8@redhat.com> (raw)
In-Reply-To: <20190919162905.21830-3-kwolf@redhat.com>
On 19/09/2019 18.29, Kevin Wolf wrote:
> Some scripts check the Python version number and have two code paths to
> accomodate both Python 2 and 3. Remove the code specific to Python 2 and
> assert the minimum version of 3.6 instead (check skips Python tests in
> this case, so the assertion would only ever trigger if a Python script
> is executed manually).
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> tests/qemu-iotests/044 | 3 ---
> tests/qemu-iotests/163 | 3 ---
> tests/qemu-iotests/iotests.py | 13 +++----------
> tests/qemu-iotests/nbd-fault-injector.py | 7 +++----
> 4 files changed, 6 insertions(+), 20 deletions(-)
>
> diff --git a/tests/qemu-iotests/044 b/tests/qemu-iotests/044
> index 05ea1f49c5..8b2afa2a11 100755
> --- a/tests/qemu-iotests/044
> +++ b/tests/qemu-iotests/044
> @@ -28,9 +28,6 @@ import struct
> import subprocess
> import sys
>
> -if sys.version_info.major == 2:
> - range = xrange
> -
> test_img = os.path.join(iotests.test_dir, 'test.img')
>
> class TestRefcountTableGrowth(iotests.QMPTestCase):
> diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
> index 081ccc8ac1..d94728e080 100755
> --- a/tests/qemu-iotests/163
> +++ b/tests/qemu-iotests/163
> @@ -21,9 +21,6 @@
> import os, random, iotests, struct, qcow2, sys
> from iotests import qemu_img, qemu_io, image_size
>
> -if sys.version_info.major == 2:
> - range = xrange
> -
> test_img = os.path.join(iotests.test_dir, 'test.img')
> check_img = os.path.join(iotests.test_dir, 'check.img')
>
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index b26271187c..9fb5181c3d 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -35,6 +35,7 @@ from collections import OrderedDict
> sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
> from qemu import qtest
>
> +assert sys.version_info >= (3,6)
>
> # This will not work if arguments contain spaces but is necessary if we
> # want to support the override options that ./check supports.
> @@ -250,10 +251,7 @@ def image_size(img):
> return json.loads(r)['virtual-size']
>
> def is_str(val):
> - if sys.version_info.major >= 3:
> - return isinstance(val, str)
> - else:
> - return isinstance(val, str) or isinstance(val, unicode)
> + return isinstance(val, str)
>
> test_dir_re = re.compile(r"%s" % test_dir)
> def filter_test_dir(msg):
> @@ -935,12 +933,7 @@ def execute_test(test_function=None,
> else:
> # We need to filter out the time taken from the output so that
> # qemu-iotest can reliably diff the results against master output.
> - if sys.version_info.major >= 3:
> - output = io.StringIO()
> - else:
> - # io.StringIO is for unicode strings, which is not what
> - # 2.x's test runner emits.
> - output = io.BytesIO()
> + output = io.StringIO()
>
> logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
>
> diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
> index 6b2d659dee..43f095ceef 100755
> --- a/tests/qemu-iotests/nbd-fault-injector.py
> +++ b/tests/qemu-iotests/nbd-fault-injector.py
> @@ -48,10 +48,9 @@ import sys
> import socket
> import struct
> import collections
> -if sys.version_info.major >= 3:
> - import configparser
> -else:
> - import ConfigParser as configparser
> +import configparser
> +
> +assert sys.version_info >= (3,6)
>
> FAKE_DISK_SIZE = 8 * 1024 * 1024 * 1024 # 8 GB
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2019-09-19 16:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 16:29 [PATCH v2 0/2] iotests: Require Python 3.6 or later Kevin Wolf
2019-09-19 16:29 ` [PATCH v2 1/2] " Kevin Wolf
2019-09-19 16:38 ` Eduardo Habkost
2019-09-19 16:41 ` Thomas Huth
2019-09-20 8:40 ` Vladimir Sementsov-Ogievskiy
2019-09-20 9:27 ` Kevin Wolf
2019-09-20 9:44 ` Vladimir Sementsov-Ogievskiy
2019-09-19 16:29 ` [PATCH v2 2/2] iotests: Remove Python 2 compatibility code Kevin Wolf
2019-09-19 16:38 ` Eduardo Habkost
2019-09-19 16:42 ` Thomas Huth [this message]
2019-09-19 19:14 ` John Snow
2019-09-20 8:51 ` Vladimir Sementsov-Ogievskiy
2019-09-19 17:15 ` [PATCH v2 0/2] iotests: Require Python 3.6 or later Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=09a9cf74-a6f0-bce7-ceac-052cd8ea7ae8@redhat.com \
--to=thuth@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).