Skip to content

Commit da21fc5

Browse files
Improve output for missing required plugins/unknown config keys (#7723)
Co-authored-by: Florian Bruhin <[email protected]>
1 parent cdf2024 commit da21fc5

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

changelog/7572.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When a plugin listed in ``required_plugins`` is missing, a simple error message is now shown instead of a stacktrace.

src/_pytest/config/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,8 @@ def _validate_plugins(self) -> None:
12461246
missing_plugins.append(required_plugin)
12471247

12481248
if missing_plugins:
1249-
fail(
1249+
raise UsageError(
12501250
"Missing required plugins: {}".format(", ".join(missing_plugins)),
1251-
pytrace=False,
12521251
)
12531252

12541253
def _warn_or_fail_if_strict(self, message: str) -> None:

testing/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def my_dists():
407407
testdir.makeini(ini_file_text)
408408

409409
if exception_text:
410-
with pytest.raises(pytest.fail.Exception, match=exception_text):
410+
with pytest.raises(pytest.UsageError, match=exception_text):
411411
testdir.parseconfig()
412412
else:
413413
testdir.parseconfig()

0 commit comments

Comments
 (0)