Skip to content

Commit ef900b0

Browse files
author
Bojan Nikolic
committed
Update test case style as per review
1 parent 44c0184 commit ef900b0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Lib/test/test_shutil.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,14 +3379,16 @@ def syscall(*args, **kwargs):
33793379
flag = []
33803380
orig_syscall = eval(self.PATCHPOINT)
33813381
# Reduce block size so that multiple syscalls are needed
3382-
mock = unittest.mock.Mock()
3383-
mock.st_size = 65536 + 1
3384-
with unittest.mock.patch('os.fstat', return_value=mock) as m:
3385-
with unittest.mock.patch(self.PATCHPOINT, create=True,
3386-
side_effect=syscall) as m2:
3387-
with self.get_files() as (src, dst):
3388-
with self.assertRaises(_GiveupOnFastCopy) as cm:
3389-
self.zerocopy_fun(src, dst)
3382+
fstat_mock = unittest.mock.Mock()
3383+
fstat_mock.st_size = 65536 + 1
3384+
with unittest.mock.patch('os.fstat', return_value=fstat_mock):
3385+
with (
3386+
unittest.mock.patch(self.PATCHPOINT, create=True,
3387+
side_effect=syscall),
3388+
self.get_files() as (src, dst)
3389+
):
3390+
self.assertRaises(_GiveupOnFastCopy,
3391+
self.zerocopy_fun, src, dst)
33903392

33913393
# Reset flag so that second syscall fails again
33923394
flag.clear()
@@ -3396,9 +3398,10 @@ def syscall(*args, **kwargs):
33963398
shutil.copyfile(TESTFN, TESTFN2)
33973399
m2.assert_called()
33983400
shutil._USE_CP_SENDFILE = True
3399-
assert flag
3401+
self.assertEqual(flag, [None])
34003402
self.assertEqual(read_file(TESTFN2, binary=True), self.FILEDATA)
34013403

3404+
34023405
@unittest.skipUnless(shutil._USE_CP_COPY_FILE_RANGE, "os.copy_file_range() not supported")
34033406
class TestZeroCopyCopyFileRange(_ZeroCopyFileLinuxTest, unittest.TestCase):
34043407
PATCHPOINT = "os.copy_file_range"

0 commit comments

Comments
 (0)