MCPcopy Create free account
hub / github.com/pytest-dev/pytest / validate_basetemp

Function validate_basetemp

src/_pytest/main.py:230–252  ·  view source on GitHub ↗
(path: str)

Source from the content-addressed store, hash-verified

228
229
230def validate_basetemp(path: str) -> str:
231 # GH 7119
232 msg = "basetemp must not be empty, the current working directory or any parent directory of it"
233
234 # empty path
235 if not path:
236 raise argparse.ArgumentTypeError(msg)
237
238 def is_ancestor(base: Path, query: Path) -> bool:
239 """Return whether query is an ancestor of base."""
240 if base == query:
241 return True
242 return query in base.parents
243
244 # check if path is an ancestor of cwd
245 if is_ancestor(Path.cwd(), Path(path).absolute()):
246 raise argparse.ArgumentTypeError(msg)
247
248 # check symlinks for ancestors
249 if is_ancestor(Path.cwd().resolve(), Path(path).resolve()):
250 raise argparse.ArgumentTypeError(msg)
251
252 return path
253
254
255def wrap_session(

Callers 2

Calls 1

is_ancestorFunction · 0.85

Tested by 2