MCPcopy
hub / github.com/pytest-dev/pytest / mksymlinkto

Method mksymlinkto

src/_pytest/_py/path.py:324–335  ·  view source on GitHub ↗

Create a symbolic link with the given value (pointing to another name).

(self, value, absolute=1)

Source from the content-addressed store, hash-verified

322 error.checked_call(os.link, str(oldname), str(self))
323
324 def mksymlinkto(self, value, absolute=1):
325 """Create a symbolic link with the given value (pointing to another name)."""
326 if absolute:
327 error.checked_call(os.symlink, str(value), self.strpath)
328 else:
329 base = self.common(value)
330 # with posix local paths '/' is always a common base
331 relsource = self.__class__(value).relto(base)
332 reldest = self.relto(base)
333 n = reldest.count(self.sep)
334 target = self.sep.join(("..",) * n + (relsource,))
335 error.checked_call(os.symlink, target, self.strpath)
336
337 def __div__(self, other):
338 return self.join(os.fspath(other))

Callers 10

copyMethod · 0.80
create_lockfileMethod · 0.80
test_symlink_isfileMethod · 0.80
test_symlink_relativeMethod · 0.80
test_symlink_isdirMethod · 0.80
test_symlink_removeMethod · 0.80
test_realpath_fileMethod · 0.80

Calls 6

commonMethod · 0.95
reltoMethod · 0.95
checked_callMethod · 0.80
joinMethod · 0.80
reltoMethod · 0.45
__class__Method · 0.45

Tested by 8

test_symlink_isfileMethod · 0.64
test_symlink_relativeMethod · 0.64
test_symlink_isdirMethod · 0.64
test_symlink_removeMethod · 0.64
test_realpath_fileMethod · 0.64