Skip to content

Commit

Permalink
Allow spaces in -p arguments (#10658)
Browse files Browse the repository at this point in the history
  • Loading branch information
k4nar committed Jan 21, 2023
1 parent bd7919e commit af41437
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ Wouter van Ackooy
Xixi Zhao
Xuan Luong
Xuecong Liao
Yannick Péroux
Yoav Caspi
Yuliang Shao
Yusuke Kadowaki
Expand Down
3 changes: 3 additions & 0 deletions changelog/10658.improvement.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ def consider_preparse(
parg = opt[2:]
else:
continue
parg = parg.strip()
if exclude_only and not parg.startswith("no:"):
continue
self.consider_pluginarg(parg)
Expand Down
4 changes: 4 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
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:
"""Ensure that Config.invocation_* arguments are correctly defined"""
Expand Down

0 comments on commit af41437

Please sign in to comment.