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

Method __init__

src/_pytest/_py/path.py:275–297  ·  view source on GitHub ↗

Initialize and return a local Path instance. Path can be relative to the current directory. If path is None it defaults to the current working directory. If expanduser is True, tilde-expansion is performed. Note that Path instances always carry an absolute path.

(self, path=None, expanduser=False)

Source from the content-addressed store, hash-verified

273 sep = os.sep
274
275 def __init__(self, path=None, expanduser=False):
276 """Initialize and return a local Path instance.
277
278 Path can be relative to the current directory.
279 If path is None it defaults to the current working directory.
280 If expanduser is True, tilde-expansion is performed.
281 Note that Path instances always carry an absolute path.
282 Note also that passing in a local path object will simply return
283 the exact same path object. Use new() to get a new copy.
284 """
285 if path is None:
286 self.strpath = error.checked_call(os.getcwd)
287 else:
288 try:
289 path = os.fspath(path)
290 except TypeError:
291 raise ValueError(
292 "can only pass None, Path instances "
293 "or non-empty strings to LocalPath"
294 )
295 if expanduser:
296 path = os.path.expanduser(path)
297 self.strpath = abspath(path)
298
299 if sys.platform != "win32":
300

Callers

nothing calls this directly

Calls 2

checked_callMethod · 0.80
fspathMethod · 0.80

Tested by

no test coverage detected