diff --git a/tests/test_multistore_file.py b/tests/test_multistore_file.py index 347e47da8..1e8c5011f 100644 --- a/tests/test_multistore_file.py +++ b/tests/test_multistore_file.py @@ -32,9 +32,12 @@ def test_lock_file_raises_ioerror(self): filehandle, filename = tempfile.mkstemp() os.close(filehandle) - for error_code in (errno.EDEADLK, errno.ENOSYS, errno.ENOLCK): - multistore = multistore_file._MultiStore(filename) - multistore._file = _MockLockedFile(filename, error_code) - # Should not raise even though the underlying file class did. - multistore._lock() - self.assertTrue(multistore._file.open_and_lock_called) + try: + for error_code in (errno.EDEADLK, errno.ENOSYS, errno.ENOLCK): + multistore = multistore_file._MultiStore(filename) + multistore._file = _MockLockedFile(filename, error_code) + # Should not raise even though the underlying file class did. + multistore._lock() + self.assertTrue(multistore._file.open_and_lock_called) + finally: + os.unlink(filename)