aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-09-19 18:18:31 +0200
committerKevin Wolf <kwolf@redhat.com>2019-10-04 11:59:16 +0200
commit7e693a0500455edab21754573c32b7146138cffd (patch)
tree973d0e002fe096b3973358d2e53cb3062d48a420 /tests/qemu-iotests
parentc69719fcadbc856db5348fd3401e65e38c10a22e (diff)
iotests: Remove Python 2 compatibility code
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> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'tests/qemu-iotests')
-rwxr-xr-xtests/qemu-iotests/0443
-rwxr-xr-xtests/qemu-iotests/1633
-rw-r--r--tests/qemu-iotests/iotests.py13
3 files changed, 3 insertions, 16 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))