MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_win_impl

Method test_win_impl

Lib/test/test_shutil.py:3115–3142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3113
3114 @unittest.skipIf(os.name != 'nt', "Windows only")
3115 def test_win_impl(self):
3116 # Make sure alternate Windows implementation is called.
3117 with unittest.mock.patch("shutil._copyfileobj_readinto") as m:
3118 shutil.copyfile(TESTFN, TESTFN2)
3119 assert m.called
3120
3121 # File size is 2 MiB but max buf size should be 1 MiB.
3122 self.assertEqual(m.call_args[0][2], 1 * 1024 * 1024)
3123
3124 # If file size < 1 MiB memoryview() length must be equal to
3125 # the actual file size.
3126 with tempfile.NamedTemporaryFile(dir=os.getcwd(), delete=False) as f:
3127 f.write(b'foo')
3128 fname = f.name
3129 self.addCleanup(os_helper.unlink, fname)
3130 with unittest.mock.patch("shutil._copyfileobj_readinto") as m:
3131 shutil.copyfile(fname, TESTFN2)
3132 self.assertEqual(m.call_args[0][2], 3)
3133
3134 # Empty files should not rely on readinto() variant.
3135 with tempfile.NamedTemporaryFile(dir=os.getcwd(), delete=False) as f:
3136 pass
3137 fname = f.name
3138 self.addCleanup(os_helper.unlink, fname)
3139 with unittest.mock.patch("shutil._copyfileobj_readinto") as m:
3140 shutil.copyfile(fname, TESTFN2)
3141 assert not m.called
3142 self.assert_files_eq(fname, TESTFN2)
3143
3144
3145class _ZeroCopyFileTest(object):

Callers

nothing calls this directly

Calls 5

assert_files_eqMethod · 0.95
copyfileMethod · 0.80
addCleanupMethod · 0.80
assertEqualMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected