Merge pull request #5278 from blueyed/disable-python-plugin
Allow disabling of python plugin
This commit is contained in:
commit
6c56070df1
|
@ -0,0 +1 @@
|
||||||
|
Pytest's internal python plugin can be disabled using ``-p python`` now again.
|
|
@ -60,7 +60,10 @@ class AssertionRewritingHook(object):
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = 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.session = None
|
||||||
self.modules = {}
|
self.modules = {}
|
||||||
self._rewritten_names = set()
|
self._rewritten_names = set()
|
||||||
|
|
|
@ -113,16 +113,16 @@ def directory_arg(path, optname):
|
||||||
|
|
||||||
|
|
||||||
# Plugins that cannot be disabled via "-p no:X" currently.
|
# Plugins that cannot be disabled via "-p no:X" currently.
|
||||||
essential_plugins = (
|
essential_plugins = ( # fmt: off
|
||||||
"mark",
|
"mark",
|
||||||
"main",
|
"main",
|
||||||
"runner",
|
"runner",
|
||||||
"python",
|
|
||||||
"fixtures",
|
"fixtures",
|
||||||
"helpconfig", # Provides -p.
|
"helpconfig", # Provides -p.
|
||||||
)
|
) # fmt: on
|
||||||
|
|
||||||
default_plugins = essential_plugins + (
|
default_plugins = essential_plugins + (
|
||||||
|
"python",
|
||||||
"terminal",
|
"terminal",
|
||||||
"debugging",
|
"debugging",
|
||||||
"unittest",
|
"unittest",
|
||||||
|
|
|
@ -1075,6 +1075,15 @@ def pytestconfig(request):
|
||||||
return request.config
|
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):
|
class FixtureManager(object):
|
||||||
"""
|
"""
|
||||||
pytest fixtures definitions and information is stored and managed
|
pytest fixtures definitions and information is stored and managed
|
||||||
|
|
|
@ -79,15 +79,10 @@ def pytest_addoption(parser):
|
||||||
default=False,
|
default=False,
|
||||||
help="show fixtures per test",
|
help="show fixtures per test",
|
||||||
)
|
)
|
||||||
parser.addini(
|
|
||||||
"usefixtures",
|
|
||||||
type="args",
|
|
||||||
default=[],
|
|
||||||
help="list of default fixtures to be used with this project",
|
|
||||||
)
|
|
||||||
parser.addini(
|
parser.addini(
|
||||||
"python_files",
|
"python_files",
|
||||||
type="args",
|
type="args",
|
||||||
|
# NOTE: default is also used in AssertionRewritingHook.
|
||||||
default=["test_*.py", "*_test.py"],
|
default=["test_*.py", "*_test.py"],
|
||||||
help="glob-style file patterns for Python test module discovery",
|
help="glob-style file patterns for Python test module discovery",
|
||||||
)
|
)
|
||||||
|
|
|
@ -1228,6 +1228,17 @@ def test_config_blocked_default_plugins(testdir, plugin):
|
||||||
|
|
||||||
p = testdir.makepyfile("def test(): pass")
|
p = testdir.makepyfile("def test(): pass")
|
||||||
result = testdir.runpytest(str(p), "-pno:%s" % plugin)
|
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
|
assert result.ret == EXIT_OK
|
||||||
if plugin != "terminal":
|
if plugin != "terminal":
|
||||||
result.stdout.fnmatch_lines(["* 1 passed in *"])
|
result.stdout.fnmatch_lines(["* 1 passed in *"])
|
||||||
|
|
Loading…
Reference in New Issue