aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/config/findpaths.py
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-14 00:49:36 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-14 00:49:36 +0300
commit82cfd1b7cab2d843cdf5467d9737f72597a493bd (patch)
tree1dfdcfe81a1a6b193ceacc2a828c521b657a339b /contrib/python/pytest/py3/_pytest/config/findpaths.py
parent3df7211d3e3691f8e33b0a1fb1764fe810d59302 (diff)
downloadydb-82cfd1b7cab2d843cdf5467d9737f72597a493bd.tar.gz
intermediate changes
ref:68b1302de4b5da30b6bdf02193f7a2604d8b5cf8
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/config/findpaths.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/config/findpaths.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/contrib/python/pytest/py3/_pytest/config/findpaths.py b/contrib/python/pytest/py3/_pytest/config/findpaths.py
index 2edf54536b..89ade5f23b 100644
--- a/contrib/python/pytest/py3/_pytest/config/findpaths.py
+++ b/contrib/python/pytest/py3/_pytest/config/findpaths.py
@@ -64,9 +64,13 @@ def load_config_dict_from_file(
# '.toml' files are considered if they contain a [tool.pytest.ini_options] table.
elif filepath.suffix == ".toml":
- import toml
+ import tomli
- config = toml.load(str(filepath))
+ toml_text = filepath.read_text(encoding="utf-8")
+ try:
+ config = tomli.loads(toml_text)
+ except tomli.TOMLDecodeError as exc:
+ raise UsageError(str(exc)) from exc
result = config.get("tool", {}).get("pytest", {}).get("ini_options", None)
if result is not None:
@@ -83,9 +87,7 @@ def load_config_dict_from_file(
def locate_config(
args: Iterable[Path],
-) -> Tuple[
- Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]],
-]:
+) -> Tuple[Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]]]:
"""Search in the list of arguments for a valid ini-file for pytest,
and return a tuple of (rootdir, inifile, cfg-dict)."""
config_names = [
@@ -178,7 +180,7 @@ def determine_setup(
inipath: Optional[Path] = inipath_
inicfg = load_config_dict_from_file(inipath_) or {}
if rootdir_cmd_arg is None:
- rootdir = get_common_ancestor(dirs)
+ rootdir = inipath_.parent
else:
ancestor = get_common_ancestor(dirs)
rootdir, inipath, inicfg = locate_config([ancestor])