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

Function directory_arg

src/_pytest/config/__init__.py:214–222  ·  view source on GitHub ↗

Argparse type validator for directory arguments. :path: Path of directory. :optname: Name of the option.

(path: str, optname: str)

Source from the content-addressed store, hash-verified

212
213
214def directory_arg(path: str, optname: str) -> str:
215 """Argparse type validator for directory arguments.
216
217 :path: Path of directory.
218 :optname: Name of the option.
219 """
220 if not os.path.isdir(path):
221 raise UsageError(f"{optname} must be a directory, given: {path}")
222 return path
223
224
225# Plugins that cannot be disabled via "-p no:X" currently.

Callers

nothing calls this directly

Calls 1

UsageErrorClass · 0.85

Tested by

no test coverage detected