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

Function locate_config

src/_pytest/config/findpaths.py:88–111  ·  view source on GitHub ↗

Search in the list of arguments for a valid ini-file for pytest, and return a tuple of (rootdir, inifile, cfg-dict).

(
    args: Iterable[Path],
)

Source from the content-addressed store, hash-verified

86
87
88def locate_config(
89 args: Iterable[Path],
90) -> Tuple[Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]]]:
91 """Search in the list of arguments for a valid ini-file for pytest,
92 and return a tuple of (rootdir, inifile, cfg-dict)."""
93 config_names = [
94 "pytest.ini",
95 "pyproject.toml",
96 "tox.ini",
97 "setup.cfg",
98 ]
99 args = [x for x in args if not str(x).startswith("-")]
100 if not args:
101 args = [Path.cwd()]
102 for arg in args:
103 argpath = absolutepath(arg)
104 for base in (argpath, *argpath.parents):
105 for config_name in config_names:
106 p = base / config_name
107 if p.is_file():
108 ini_config = load_config_dict_from_file(p)
109 if ini_config is not None:
110 return base, p, ini_config
111 return None, None, {}
112
113
114def get_common_ancestor(paths: Iterable[Path]) -> Path:

Callers 2

determine_setupFunction · 0.85

Calls 2

absolutepathFunction · 0.90

Tested by 1