(
args: list[str] | os.PathLike[str],
plugins: Sequence[str | _PluggyPlugin] | None = None,
*,
prog: str | None = None,
)
| 385 | |
| 386 | |
| 387 | def _prepareconfig( |
| 388 | args: list[str] | os.PathLike[str], |
| 389 | plugins: Sequence[str | _PluggyPlugin] | None = None, |
| 390 | *, |
| 391 | prog: str | None = None, |
| 392 | ) -> Config: |
| 393 | if isinstance(args, os.PathLike): |
| 394 | args = [os.fspath(args)] |
| 395 | elif not isinstance(args, list): |
| 396 | msg = ( # type:ignore[unreachable] |
| 397 | "`args` parameter expected to be a list of strings, got: {!r} (type: {})" |
| 398 | ) |
| 399 | raise TypeError(msg.format(args, type(args))) |
| 400 | |
| 401 | initial_config = get_config(args, plugins, prog=prog) |
| 402 | pluginmanager = initial_config.pluginmanager |
| 403 | try: |
| 404 | if plugins: |
| 405 | for plugin in plugins: |
| 406 | if isinstance(plugin, str): |
| 407 | pluginmanager.consider_pluginarg(plugin) |
| 408 | else: |
| 409 | pluginmanager.register(plugin) |
| 410 | config: Config = pluginmanager.hook.pytest_cmdline_parse( |
| 411 | pluginmanager=pluginmanager, args=args |
| 412 | ) |
| 413 | return config |
| 414 | except BaseException: |
| 415 | initial_config._ensure_unconfigure() |
| 416 | raise |
| 417 | |
| 418 | |
| 419 | def _get_directory(path: pathlib.Path) -> pathlib.Path: |
no test coverage detected