Skip to content

Commit 966d0b3

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "fix qemu-img version dependent tests" into unmaintained/zed
2 parents 29d11ce + dae4230 commit 966d0b3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

nova/tests/unit/image/test_format_inspector.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,22 @@ def _create_img(
111111
if fmt == 'iso':
112112
return self._create_iso(size, subformat)
113113

114-
# these tests depend on qemu-img
115-
# being installed and in the path,
116-
# if it is not installed, skip
117-
try:
118-
subprocess.check_output('qemu-img --version', shell=True)
119-
except Exception:
120-
self.skipTest('qemu-img not installed')
121-
122114
if fmt == 'vhd':
123115
# QEMU calls the vhd format vpc
124116
fmt = 'vpc'
125117

118+
# these tests depend on qemu-img being installed and in the path,
119+
# if it is not installed, skip. we also need to ensure that the
120+
# format is supported by qemu-img, this can vary depending on the
121+
# distribution so we need to check if the format is supported via
122+
# the help output.
123+
try:
124+
subprocess.check_output(
125+
'qemu-img --help | grep %s' % fmt, shell=True)
126+
except Exception:
127+
self.skipTest(
128+
'qemu-img not installed or does not support %s format' % fmt)
129+
126130
if options is None:
127131
options = {}
128132
opt = ''

0 commit comments

Comments
 (0)