Skip to content

Commit bdde2ac

Browse files
committed
Add -p no:[defaults] to disable non-essential default plugins
`[defaults]` is used since it is an invalid name for entrypoints. This is useful for debugging at least. test_help: use `-p no:[defaults]` Adjust test, which currently would match options from hypothesis (if installed), - `--verbosity` itself is apparently not an essential plugin.. (-‸ლ) Closes #66.
1 parent 330e4fc commit bdde2ac

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎src/_pytest/config/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ def consider_pluginarg(self, arg):
515515
if name in essential_plugins:
516516
raise UsageError("plugin %s cannot be disabled" % name)
517517

518+
if name == "[defaults]":
519+
for p in builtin_plugins.difference(essential_plugins):
520+
self.set_blocked(p)
521+
518522
# PR #4304 : remove stepwise if cacheprovider is blocked
519523
if name == "cacheprovider":
520524
self.set_blocked("stepwise")

‎src/_pytest/helpconfig.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def pytest_addoption(parser):
5858
metavar="name",
5959
help="early-load given plugin module name or entry point (multi-allowed). "
6060
"To avoid loading of plugins, use the `no:` prefix, e.g. "
61-
"`no:doctest`.",
61+
"`no:doctest`. "
62+
"`no:[defaults]` disables all non-essential default plugins.",
6263
)
6364
group.addoption(
6465
"--traceconfig",

‎testing/test_helpconfig.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ def test_version(testdir, pytestconfig):
1414

1515

1616
def test_help(testdir):
17-
result = testdir.runpytest("--help")
17+
result = testdir.runpytest("--help", "-p", "no:[defaults]")
1818
assert result.ret == 0
1919
result.stdout.fnmatch_lines(
2020
"""
21-
*-v*verbose*
21+
reporting:
22+
--durations=N *
2223
*setup.cfg*
2324
*minversion*
2425
*to see*markers*pytest --markers*
2526
*to see*fixtures*pytest --fixtures*
2627
"""
2728
)
29+
result.stdout.no_fnmatch_line("logging:")
2830

2931

3032
def test_hookvalidation_unknown(testdir):

0 commit comments

Comments
 (0)