(
args: Optional[Union[List[str], "os.PathLike[str]"]] = None,
plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None,
)
| 302 | |
| 303 | |
| 304 | def _prepareconfig( |
| 305 | args: Optional[Union[List[str], "os.PathLike[str]"]] = None, |
| 306 | plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None, |
| 307 | ) -> "Config": |
| 308 | if args is None: |
| 309 | args = sys.argv[1:] |
| 310 | elif isinstance(args, os.PathLike): |
| 311 | args = [os.fspath(args)] |
| 312 | elif not isinstance(args, list): |
| 313 | msg = "`args` parameter expected to be a list of strings, got: {!r} (type: {})" |
| 314 | raise TypeError(msg.format(args, type(args))) |
| 315 | |
| 316 | config = get_config(args, plugins) |
| 317 | pluginmanager = config.pluginmanager |
| 318 | try: |
| 319 | if plugins: |
| 320 | for plugin in plugins: |
| 321 | if isinstance(plugin, str): |
| 322 | pluginmanager.consider_pluginarg(plugin) |
| 323 | else: |
| 324 | pluginmanager.register(plugin) |
| 325 | config = pluginmanager.hook.pytest_cmdline_parse( |
| 326 | pluginmanager=pluginmanager, args=args |
| 327 | ) |
| 328 | return config |
| 329 | except BaseException: |
| 330 | config._ensure_unconfigure() |
| 331 | raise |
| 332 | |
| 333 | |
| 334 | def _get_directory(path: Path) -> Path: |
no test coverage detected