diff options
author | Max Reitz <mreitz@redhat.com> | 2019-02-10 15:57:32 +0100 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2019-02-25 15:11:28 +0100 |
commit | 011a576113000f9c90a8450ef9116cca8d6f2523 (patch) | |
tree | 53e6f6c5fb742ae0418a8a20dd94c55095cea84e /tests/qemu-iotests | |
parent | 9ac10f2e2c93e647ba6830c7083310aa04f65021 (diff) | |
download | qemu-011a576113000f9c90a8450ef9116cca8d6f2523.zip qemu-011a576113000f9c90a8450ef9116cca8d6f2523.tar.gz qemu-011a576113000f9c90a8450ef9116cca8d6f2523.tar.bz2 |
iotests.py: Add is_str()
On Python 2.x, strings are not always unicode strings. This function
checks whether a given value is a plain string, or a unicode string (if
there is a difference).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 20190210145736.1486-7-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests')
-rw-r--r-- | tests/qemu-iotests/iotests.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 82dd096..52fc775 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -236,6 +236,12 @@ def image_size(img): r = qemu_img_pipe('info', '--output=json', '-f', imgfmt, 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) + test_dir_re = re.compile(r"%s" % test_dir) def filter_test_dir(msg): return test_dir_re.sub("TEST_DIR", msg) |