@@ -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
Just like we have file_path() as an alternative to FilePath, this is an alternative fo ImagePath. Signed-off-by: Max Reitz <mreitz@redhat.com> --- tests/qemu-iotests/iotests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)