MCPcopy Index your code
hub / github.com/python/cpython / test_copyfile_same_file

Method test_copyfile_same_file

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

Source from the content-addressed store, hash-verified

1569 self.assertEqual(read_file(src_file), read_file(dst_file))
1570
1571 def test_copyfile_same_file(self):
1572 # copyfile() should raise SameFileError if the source and destination
1573 # are the same.
1574 src_dir = self.mkdtemp()
1575 src_file = os.path.join(src_dir, 'foo')
1576 create_file(src_file, 'foo')
1577 self.assertRaises(SameFileError, shutil.copyfile, src_file, src_file)
1578 # But Error should work too, to stay backward compatible.
1579 self.assertRaises(Error, shutil.copyfile, src_file, src_file)
1580 # Make sure file is not corrupted.
1581 self.assertEqual(read_file(src_file), 'foo')
1582
1583 @unittest.skipIf(MACOS or SOLARIS or _winapi, 'On MACOS, Solaris and Windows the errors are not confusing (though different)')
1584 # gh-92670: The test uses a trailing slash to force the OS consider

Callers

nothing calls this directly

Calls 6

read_fileFunction · 0.85
mkdtempMethod · 0.80
create_fileFunction · 0.70
joinMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected