From 3c4fb67a2de8471c1e63edfff8d69451f0296f76 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 16 May 2016 06:09:38 +0200 Subject: [PATCH] python/tests/utils.py: try reopening the file is deleting it fails on windows --- python/tests/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/tests/utils.py b/python/tests/utils.py index 4e4ac71d..2e3c31e5 100644 --- a/python/tests/utils.py +++ b/python/tests/utils.py @@ -29,7 +29,16 @@ def get_tmp_sink_path(): return path def del_tmp_sink_path(path): - os.unlink(path) + try: + os.unlink(path) + except WindowsError as e: + print("deleting {:s} failed ({:s}), reopening".format(path, repr(e))) + with open(path, 'wb') as f: + f.close() + try: + os.unlink(path) + except WindowsError as f: + print("deleting {:s} failed ({:s}), aborting".format(path, repr(e))) def array_from_yaml_file(filename): import yaml -- 2.11.0