mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a test with locked file on windows
This commit is contained in:
parent
e25f8bf61c
commit
5db45f0563
@ -91,7 +91,7 @@ class WindowsFileCopier:
|
||||
for path, file_id in self.path_to_fileid_map.items():
|
||||
self.fileid_to_paths_map[file_id].add(path)
|
||||
for src in self.copy_map:
|
||||
self.path_to_handle_map = self._open_file(src)
|
||||
self.path_to_handle_map[src] = self._open_file(src)
|
||||
|
||||
def __exit__(self, *a) -> None:
|
||||
for h in self.path_to_handle_map.values():
|
||||
|
@ -7,6 +7,7 @@ import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from calibre import walk
|
||||
from calibre.constants import iswindows
|
||||
|
||||
from .copy_files import copy_tree
|
||||
@ -79,6 +80,14 @@ class TestCopyFiles(unittest.TestCase):
|
||||
if not iswindows:
|
||||
self.ae(os.readlink(self.d('link.extra')), 'sub/a')
|
||||
|
||||
self.reset()
|
||||
src, dest = self.s(), self.d()
|
||||
if iswindows:
|
||||
with open(self.s('sub/a')) as locked:
|
||||
locked
|
||||
self.assertRaises(IOError, copy_tree, src, dest)
|
||||
self.ae(os.listdir(self.d()), ['sub'])
|
||||
self.assertFalse(tuple(walk(self.d())))
|
||||
|
||||
def find_tests():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestCopyFiles)
|
||||
|
Loading…
x
Reference in New Issue
Block a user