Allow spaces in -p arguments (#10658)

This commit is contained in:
Yannick PÉROUX 2023-01-21 12:22:44 +01:00 committed by GitHub
parent bd7919e03d
commit af4143729f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 0 deletions

View File

@ -378,6 +378,7 @@ Wouter van Ackooy
Xixi Zhao Xixi Zhao
Xuan Luong Xuan Luong
Xuecong Liao Xuecong Liao
Yannick Péroux
Yoav Caspi Yoav Caspi
Yuliang Shao Yuliang Shao
Yusuke Kadowaki Yusuke Kadowaki

View File

@ -0,0 +1,3 @@
Allow ``-p`` arguments to include spaces (eg: ``-p no:logging`` instead of
``-pno:logging``). Mostly useful in the ``addopts`` section of the configuration
file.

View File

@ -697,6 +697,7 @@ class PytestPluginManager(PluginManager):
parg = opt[2:] parg = opt[2:]
else: else:
continue continue
parg = parg.strip()
if exclude_only and not parg.startswith("no:"): if exclude_only and not parg.startswith("no:"):
continue continue
self.consider_pluginarg(parg) self.consider_pluginarg(parg)

View File

@ -1808,6 +1808,10 @@ def test_config_does_not_load_blocked_plugin_from_args(pytester: Pytester) -> No
result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"]) result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
assert result.ret == ExitCode.USAGE_ERROR assert result.ret == ExitCode.USAGE_ERROR
result = pytester.runpytest(str(p), "-p no:capture", "-s")
result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
assert result.ret == ExitCode.USAGE_ERROR
def test_invocation_args(pytester: Pytester) -> None: def test_invocation_args(pytester: Pytester) -> None:
"""Ensure that Config.invocation_* arguments are correctly defined""" """Ensure that Config.invocation_* arguments are correctly defined"""