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

Method join

src/_pytest/_py/path.py:719–747  ·  src/_pytest/_py/path.py::LocalPath.join

Return a new path by appending all 'args' as path components. if abs=1 is used restart from root if any of the args is an absolute path.

(self, *args: os.PathLike[str], abs: bool = False)

Source from the content-addressed store, hash-verified

717 return self.new(basename=class="st">"").join(*args, **kwargs)
718
719 def join(self, *args: os.PathLike[str], abs: bool = False) -> LocalPath:
720 class="st">"""Return a new path by appending all &class="cm">#x27;args' as path
721 components. if abs=1 is used restart from root if any
722 of the args is an absolute path.
723 class="st">"""
724 sep = self.sep
725 strargs = [os.fspath(arg) for arg in args]
726 strpath = self.strpath
727 if abs:
728 newargs: list[str] = []
729 for arg in reversed(strargs):
730 if isabs(arg):
731 strpath = arg
732 strargs = newargs
733 break
734 newargs.insert(0, arg)
735 class="cm"># special case for when we have e.g. strpath == class="st">"/"
736 actual_sep = class="st">"" if strpath.endswith(sep) else sep
737 for arg in strargs:
738 arg = arg.strip(sep)
739 if iswin32:
740 class="cm"># allow unix style paths even on windows.
741 arg = arg.strip(class="st">"/")
742 arg = arg.replace(class="st">"/", sep)
743 strpath = strpath + actual_sep + arg
744 actual_sep = sep
745 obj = object.__new__(self.__class__)
746 obj.strpath = normpath(strpath)
747 return obj
748
749 def open(self, mode=class="st">"r", ensure=False, encoding=None):
750 class="st">"""Return an opened file with the given mode.

Callers 15

__div__Method · 0.95
mkdirMethod · 0.95
ensureMethod · 0.95
warnsFunction · 0.80
_sub_test_descriptionMethod · 0.80
unraisable_hookFunction · 0.80
record_testreportMethod · 0.80
_prepare_contentMethod · 0.80
raisesFunction · 0.80
_exception_type_nameFunction · 0.80
_check_matchMethod · 0.80
__repr__Method · 0.80

Calls 4

fspathMethod · 0.80
insertMethod · 0.80
endswithMethod · 0.80
stripMethod · 0.80

Tested by 15

_sub_test_descriptionMethod · 0.64
popcallMethod · 0.64
_makefileMethod · 0.64
popenMethod · 0.64
spawn_pytestMethod · 0.64
__str__Method · 0.64
_logMethod · 0.64
_log_textMethod · 0.64
_addexcinfoMethod · 0.64
repr_failureMethod · 0.64