Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/5278.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pytest's internal python plugin can be disabled using ``-p python`` now again.
5 changes: 4 additions & 1 deletion src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class AssertionRewritingHook(object):

def __init__(self, config):
self.config = config
self.fnpats = config.getini("python_files")
try:
self.fnpats = config.getini("python_files")
except ValueError:
self.fnpats = ["test_*.py", "*_test.py"]
self.session = None
self.modules = {}
self._rewritten_names = set()
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ def directory_arg(path, optname):


# Plugins that cannot be disabled via "-p no:X" currently.
essential_plugins = (
essential_plugins = ( # fmt: off
"mark",
"main",
"runner",
"python",
"fixtures",
"helpconfig", # Provides -p.
)
) # fmt: on

default_plugins = essential_plugins + (
"python",
"terminal",
"debugging",
"unittest",
Expand Down
9 changes: 9 additions & 0 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,15 @@ def test_foo(pytestconfig):
return request.config


def pytest_addoption(parser):
parser.addini(
"usefixtures",
type="args",
default=[],
help="list of default fixtures to be used with this project",
)


class FixtureManager(object):
"""
pytest fixtures definitions and information is stored and managed
Expand Down
7 changes: 1 addition & 6 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ def pytest_addoption(parser):
default=False,
help="show fixtures per test",
)
parser.addini(
"usefixtures",
type="args",
default=[],
help="list of default fixtures to be used with this project",
)
parser.addini(
"python_files",
type="args",
# NOTE: default is also used in AssertionRewritingHook.
default=["test_*.py", "*_test.py"],
help="glob-style file patterns for Python test module discovery",
)
Expand Down
11 changes: 11 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,17 @@ def test_config_blocked_default_plugins(testdir, plugin):

p = testdir.makepyfile("def test(): pass")
result = testdir.runpytest(str(p), "-pno:%s" % plugin)

if plugin == "python":
assert result.ret == EXIT_USAGEERROR
result.stderr.fnmatch_lines(
[
"ERROR: not found: */test_config_blocked_default_plugins.py",
"(no name '*/test_config_blocked_default_plugins.py' in any of [])",
]
)
return

assert result.ret == EXIT_OK
if plugin != "terminal":
result.stdout.fnmatch_lines(["* 1 passed in *"])
Expand Down