Skip to content

Commit 1500bc7

Browse files
committed
more looking for the source of the windows issues
1 parent 05d5aa0 commit 1500bc7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/shutil.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ def _dst_opener(path, flags):
444444
elif _WINDOWS and file_size > 0:
445445
_copyfileobj_readinto(fsrc, fdst, min(file_size, COPY_BUFSIZE))
446446
return dst
447-
copyfileobj(fsrc, fdst)
447+
from unittest import mock
448+
if isinstance(copyfileobj, mock.Mock):
449+
copyfileobj(fsrc, f"_WINDOWS: {_WINDOWS}\nfile_size: {file_size}")
450+
else:
451+
copyfileobj(fsrc, fdst)
448452

449453
# Issue 43219, raise a less confusing exception
450454
except IsADirectoryError as e:

Lib/test/test_shutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3133,7 +3133,7 @@ def test_win_impl(self):
31333133
with unittest.mock.patch("shutil.copyfileobj") as m4:
31343134
shutil.copyfile(TESTFN, TESTFN2)
31353135

3136-
assert m.called, f"_copyfileobj_readinto: {m.called}\n_fastcopy_fcopyfile: {m1.called}\n_fastcopy_copy_file_range: {m2.called}\n_fastcopy_sendfile: {m3.called}\ncopyfileobj: {m4.called}"
3136+
assert m.called, f"_copyfileobj_readinto: {m.called}\n_fastcopy_fcopyfile: {m1.called}\n_fastcopy_copy_file_range: {m2.called}\n_fastcopy_sendfile: {m3.called}\ncopyfileobj: {m4.called}\ncalled_with: {m4.called_with}"
31373137

31383138
# File size is 2 MiB but max buf size should be 1 MiB.
31393139
self.assertEqual(m.call_args[0][2], 1 * 1024 * 1024)

0 commit comments

Comments
 (0)