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

Method test_hardlink_to

Lib/test/test_pathlib/test_pathlib.py:2269–2284  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2267
2268 @os_helper.skip_unless_hardlink
2269 def test_hardlink_to(self):
2270 P = self.cls(self.base)
2271 target = P / 'fileA'
2272 size = target.stat().st_size
2273 # linking to another path.
2274 link = P / 'dirA' / 'fileAA'
2275 link.hardlink_to(target)
2276 self.assertEqual(link.stat().st_size, size)
2277 self.assertTrue(os.path.samefile(target, link))
2278 self.assertTrue(target.exists())
2279 # Linking to a str of a relative path.
2280 link2 = P / 'dirA' / 'fileAAA'
2281 target2 = self.parser.join(TESTFN, 'fileA')
2282 link2.hardlink_to(target2)
2283 self.assertEqual(os.stat(target2).st_size, size)
2284 self.assertTrue(link2.exists())
2285
2286 @unittest.skipIf(hasattr(os, "link"), "os.link() is present")
2287 def test_hardlink_to_unsupported(self):

Callers

nothing calls this directly

Calls 8

hardlink_toMethod · 0.80
assertTrueMethod · 0.80
samefileMethod · 0.80
clsMethod · 0.45
statMethod · 0.45
assertEqualMethod · 0.45
existsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected