Skip to content

Commit e1a4b4e

Browse files
committed
Convert TOMLDecodeError to UsageError
1 parent e942b12 commit e1a4b4e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/_pytest/config/findpaths.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def load_config_dict_from_file(
6666
elif filepath.suffix == ".toml":
6767
import tomli
6868

69-
config = tomli.loads(filepath.read_text(encoding="utf-8"))
69+
toml_text = filepath.read_text(encoding="utf-8")
70+
try:
71+
config = tomli.loads(toml_text)
72+
except tomli.TOMLDecodeError as exc:
73+
raise UsageError(str(exc)) from exc
7074

7175
result = config.get("tool", {}).get("pytest", {}).get("ini_options", None)
7276
if result is not None:

0 commit comments

Comments
 (0)