From e16690b6424e020c3a062691f91a236c46e044d0 Mon Sep 17 00:00:00 2001 From: Yannick PEROUX Date: Fri, 13 Jan 2023 11:24:11 +0100 Subject: [PATCH 1/4] CLI: Allow spaces in -p arguments --- src/_pytest/config/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 25f156f8b20..17500e79893 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -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) From 2c0ce0964d9cdd6b934bfdedda7e2e3746ef04c0 Mon Sep 17 00:00:00 2001 From: Yannick PEROUX Date: Fri, 13 Jan 2023 11:25:23 +0100 Subject: [PATCH 2/4] Add a test for '-p ' arg --- testing/test_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/test_config.py b/testing/test_config.py index f5b6d7f9816..2b6ebb53e42 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1809,6 +1809,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""" From 1d7de0dd681bee9dcb5b6c29331c33e7f751dbbe Mon Sep 17 00:00:00 2001 From: Yannick PEROUX Date: Fri, 13 Jan 2023 11:27:42 +0100 Subject: [PATCH 3/4] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index a4ca9926760..0e6fb5c9b3e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -376,6 +376,7 @@ Wouter van Ackooy Xixi Zhao Xuan Luong Xuecong Liao +Yannick PĂ©roux Yoav Caspi Yusuke Kadowaki Yuval Shimon From f402a5f99f7205a0b9796cd016319f38d6c48755 Mon Sep 17 00:00:00 2001 From: Yannick PEROUX Date: Fri, 13 Jan 2023 11:46:15 +0100 Subject: [PATCH 4/4] Add changelog entry --- changelog/10658.improvement.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/10658.improvement.rst diff --git a/changelog/10658.improvement.rst b/changelog/10658.improvement.rst new file mode 100644 index 00000000000..54e5ae84f24 --- /dev/null +++ b/changelog/10658.improvement.rst @@ -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.