Just like we have file_path() as an alternative to FilePath, this is an alternative fo ImagePath.
Signed-off-by: Max Reitz <mre...@redhat.com> --- tests/qemu-iotests/iotests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5be6ca674c..280e6c2ec2 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -505,8 +505,12 @@ def file_path_remover(): except OSError: pass +def image_path_remover(): + for path in reversed(image_path_remover.paths): + remove_test_image(path) -def file_path(*names): + +def file_path(*names, remover=file_path_remover): ''' Another way to get auto-generated filename that cleans itself up. Use is as simple as: @@ -515,19 +519,22 @@ def file_path(*names): sock = file_path('socket') ''' - if not hasattr(file_path_remover, 'paths'): - file_path_remover.paths = [] - atexit.register(file_path_remover) + if not hasattr(remover, 'paths'): + remover.paths = [] + atexit.register(remover) paths = [] for name in names: filename = file_pattern(name) path = os.path.join(test_dir, filename) - file_path_remover.paths.append(path) + remover.paths.append(path) paths.append(path) return paths[0] if len(paths) == 1 else paths +def image_path(*names): + return file_path(*names, remover=image_path_remover) + def remote_filename(path): if imgproto == 'file': return path -- 2.21.0