History

python/tests/utils.py: try reopening the file is deleting it fails on windows

Paul Brossier committed 10 years ago

Commit 3c4fb671 parent 44a3e5e1 file · +10 −1Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/utils.py+10−1
@@ -29,7 +29,16 @@ def get_tmp_sink_path(): · 28 unmodified lines
2929 return path
3030
3131 def del_tmp_sink_path(path):
32− os.unlink(path)
32+ try:
33+ os.unlink(path)
34+ except WindowsError as e:
35+ print("deleting {:s} failed ({:s}), reopening".format(path, repr(e)))
36+ with open(path, 'wb') as f:
37+ f.close()
38+ try:
39+ os.unlink(path)
40+ except WindowsError as f:
41+ print("deleting {:s} failed ({:s}), aborting".format(path, repr(e)))
3342
3443 def array_from_yaml_file(filename):
3544 import yaml

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t