Skip to content

Commit 291cdec

Browse files
committed
Fixed open file blocking delete during test.
1 parent 4794e1a commit 291cdec

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

pyrvt/tests/test_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import tempfile
2222
import shutil
23+
import time
2324

2425
from numpy.testing import assert_almost_equal, assert_allclose, \
2526
assert_equal
@@ -120,6 +121,7 @@ def check_write_events(ext):
120121
# Reload the data
121122
_ext, _periods, _events = tools.read_events(dst_fname, 'psa_target')
122123

124+
# Delete the temporary file
123125
os.unlink(dst_fname)
124126

125127
assert_equal(ext, _ext)

pyrvt/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def parse(s):
105105
wb = openpyxl.load_workbook(fname, read_only=True)
106106
ws = wb.worksheets[0]
107107
rows = [[r.value for r in row] for row in ws.rows]
108+
# Close the file so that it may be deleted if needed. This is only
109+
# important so that in the test cases the temporary .xlsx file can be
110+
# deleted.
111+
wb._archive.close()
108112
else:
109113
raise NotImplementedError
110114

0 commit comments

Comments
 (0)