Skip to content

Commit af41437

Browse files
authored
Allow spaces in -p arguments (pytest-dev#10658)
1 parent bd7919e commit af41437

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ Wouter van Ackooy
378378
Xixi Zhao
379379
Xuan Luong
380380
Xuecong Liao
381+
Yannick Péroux
381382
Yoav Caspi
382383
Yuliang Shao
383384
Yusuke Kadowaki

changelog/10658.improvement.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Allow ``-p`` arguments to include spaces (eg: ``-p no:logging`` instead of
2+
``-pno:logging``). Mostly useful in the ``addopts`` section of the configuration
3+
file.

src/_pytest/config/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ def consider_preparse(
697697
parg = opt[2:]
698698
else:
699699
continue
700+
parg = parg.strip()
700701
if exclude_only and not parg.startswith("no:"):
701702
continue
702703
self.consider_pluginarg(parg)

testing/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,10 @@ def test_config_does_not_load_blocked_plugin_from_args(pytester: Pytester) -> No
18081808
result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
18091809
assert result.ret == ExitCode.USAGE_ERROR
18101810

1811+
result = pytester.runpytest(str(p), "-p no:capture", "-s")
1812+
result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
1813+
assert result.ret == ExitCode.USAGE_ERROR
1814+
18111815

18121816
def test_invocation_args(pytester: Pytester) -> None:
18131817
"""Ensure that Config.invocation_* arguments are correctly defined"""

0 commit comments

Comments
 (0)