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

Method _decide_args

src/_pytest/config/__init__.py:1395–1438  ·  view source on GitHub ↗

Decide the args (initial paths/nodeids) to use given the relevant inputs. :param warn: Whether can issue warnings. :returns: The args and the args source. Guaranteed to be non-empty.

(
        self,
        *,
        args: list[str],
        pyargs: bool,
        testpaths: list[str],
        invocation_dir: pathlib.Path,
        rootpath: pathlib.Path,
        warn: bool,
    )

Source from the content-addressed store, hash-verified

1393 return args
1394
1395 def _decide_args(
1396 self,
1397 *,
1398 args: list[str],
1399 pyargs: bool,
1400 testpaths: list[str],
1401 invocation_dir: pathlib.Path,
1402 rootpath: pathlib.Path,
1403 warn: bool,
1404 ) -> tuple[list[str], ArgsSource]:
1405 """Decide the args (initial paths/nodeids) to use given the relevant inputs.
1406
1407 :param warn: Whether can issue warnings.
1408
1409 :returns: The args and the args source. Guaranteed to be non-empty.
1410 """
1411 if args:
1412 source = Config.ArgsSource.ARGS
1413 result = args
1414 else:
1415 if invocation_dir == rootpath:
1416 source = Config.ArgsSource.TESTPATHS
1417 if pyargs:
1418 result = testpaths
1419 else:
1420 result = []
1421 for path in testpaths:
1422 result.extend(sorted(glob.iglob(path, recursive=True)))
1423 if testpaths and not result:
1424 if warn:
1425 warning_text = (
1426 "No files were found in testpaths; "
1427 "consider removing or adjusting your testpaths configuration. "
1428 "Searching recursively from the current directory instead."
1429 )
1430 self.issue_config_time_warning(
1431 PytestConfigWarning(warning_text), stacklevel=3
1432 )
1433 else:
1434 result = []
1435 if not result:
1436 source = Config.ArgsSource.INVOCATION_DIR
1437 result = [str(invocation_dir)]
1438 return result, source
1439
1440 @hookimpl(wrapper=True)
1441 def pytest_collection(self) -> Generator[None, object, object]:

Callers 2

parseMethod · 0.95

Calls 2

PytestConfigWarningClass · 0.90

Tested by

no test coverage detected