From 4488b9e4c8b06e15b9ac3d6860655abf4f028d1b Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 01:58:20 -0500 Subject: [PATCH 1/8] feat: add `--report-chars` long option and its corresponding test --- src/_pytest/terminal.py | 1 + testing/test_config.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index e66e4f48dd6..837a78cc568 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -189,6 +189,7 @@ def pytest_addoption(parser: Parser) -> None: ) group._addoption( # private to use reserved lower-case short option "-r", + "--report-chars", action="store", dest="reportchars", default=_REPORTCHARS_DEFAULT, diff --git a/testing/test_config.py b/testing/test_config.py index cb916a8b15a..15691351cd4 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -97,6 +97,14 @@ def test_append_parse_args( assert config.option.tbstyle == "short" assert config.option.verbose + def test_report_chars_long_option( + self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch + ) -> None: + """Test that --report-chars is parsed correctly.""" + monkeypatch.setenv("PYTEST_ADDOPTS", '--report-chars=fE') + config = pytester.parseconfig(tmp_path) + assert config.option.reportchars == "fE" + def test_tox_ini_wrong_version(self, pytester: Pytester) -> None: pytester.makefile( ".ini", From 90365c87c3770412bf65568bebadfb35179c2327 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 02:08:23 -0500 Subject: [PATCH 2/8] docs: Add `--report-chars` long option to `-r` in reference documentation. --- doc/en/reference/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 57415a18cc1..d0f9c9266a4 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -2910,7 +2910,7 @@ Output and Reporting Set verbosity level explicitly. Default: 0. -.. option:: -r CHARS +.. option:: -r CHARS, --report-chars=CHARS Show extra test summary info as specified by chars: From 7a2e12ff4a416da9759fd46047706e1fdab5bbb0 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 02:10:46 -0500 Subject: [PATCH 3/8] docs: add Junhao Liao to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index a089ca678f7..55892463e30 100644 --- a/AUTHORS +++ b/AUTHORS @@ -237,6 +237,7 @@ Joseph Sawaya Josh Karpel Joshua Bronson Julian Valentin +Junhao Liao Jurko Gospodnetić Justice Ndou Justyna Janczyszyn From aaa7d0ade3717b79593b510ea658e18af7e16fa3 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 02:14:26 -0500 Subject: [PATCH 4/8] add changelog --- changelog/14023.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/14023.feature.rst diff --git a/changelog/14023.feature.rst b/changelog/14023.feature.rst new file mode 100644 index 00000000000..c5449271212 --- /dev/null +++ b/changelog/14023.feature.rst @@ -0,0 +1 @@ +Added --report-chars long CLI option. \ No newline at end of file From 8ba1639ff6d57c647b327fb3d92cc735661688c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 07:15:01 +0000 Subject: [PATCH 5/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/14023.feature.rst | 2 +- testing/test_config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/14023.feature.rst b/changelog/14023.feature.rst index c5449271212..67c5cd75ead 100644 --- a/changelog/14023.feature.rst +++ b/changelog/14023.feature.rst @@ -1 +1 @@ -Added --report-chars long CLI option. \ No newline at end of file +Added --report-chars long CLI option. diff --git a/testing/test_config.py b/testing/test_config.py index 15691351cd4..1062e0888dc 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -101,7 +101,7 @@ def test_report_chars_long_option( self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch ) -> None: """Test that --report-chars is parsed correctly.""" - monkeypatch.setenv("PYTEST_ADDOPTS", '--report-chars=fE') + monkeypatch.setenv("PYTEST_ADDOPTS", "--report-chars=fE") config = pytester.parseconfig(tmp_path) assert config.option.reportchars == "fE" From 12bd5ae04c9842093d99ac69e350a4bcd3dbc26e Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 02:17:27 -0500 Subject: [PATCH 6/8] docs: format CLI option in changelog entry --- changelog/14023.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/14023.feature.rst b/changelog/14023.feature.rst index 67c5cd75ead..5d0f07c942e 100644 --- a/changelog/14023.feature.rst +++ b/changelog/14023.feature.rst @@ -1 +1 @@ -Added --report-chars long CLI option. +Added `--report-chars` long CLI option. From c116ac0b7d6063e81d3ea2858a3d1d21fc8f9b55 Mon Sep 17 00:00:00 2001 From: Junhao Liao Date: Tue, 2 Dec 2025 13:23:48 -0500 Subject: [PATCH 7/8] test: parameterize report-chars option parsing to cover short and long forms with various values. --- testing/test_config.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/testing/test_config.py b/testing/test_config.py index 1062e0888dc..e76f01e1ec5 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -97,13 +97,29 @@ def test_append_parse_args( assert config.option.tbstyle == "short" assert config.option.verbose - def test_report_chars_long_option( - self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch + @pytest.mark.parametrize( + "opts, expected", + [ + ("-rfE", "fE"), + ("--report-chars=fE", "fE"), + ("-rA", "A"), + ("--report-chars=A", "A"), + ("-rfs", "fs"), + ("--report-chars=fs", "fs"), + ], + ) + def test_report_chars_option( + self, + pytester: Pytester, + tmp_path: Path, + monkeypatch: MonkeyPatch, + opts: str, + expected: str, ) -> None: - """Test that --report-chars is parsed correctly.""" - monkeypatch.setenv("PYTEST_ADDOPTS", "--report-chars=fE") + """Test that -r/--report-chars is parsed correctly.""" + monkeypatch.setenv("PYTEST_ADDOPTS", opts) config = pytester.parseconfig(tmp_path) - assert config.option.reportchars == "fE" + assert config.option.reportchars == expected def test_tox_ini_wrong_version(self, pytester: Pytester) -> None: pytester.makefile( From 6c3b2bab072a724bdfc85580231fa804b37fdef7 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 4 Dec 2025 15:54:11 +0100 Subject: [PATCH 8/8] make parametrize nicer --- testing/test_config.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/testing/test_config.py b/testing/test_config.py index e76f01e1ec5..44ac0ca2aa7 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -97,29 +97,20 @@ def test_append_parse_args( assert config.option.tbstyle == "short" assert config.option.verbose - @pytest.mark.parametrize( - "opts, expected", - [ - ("-rfE", "fE"), - ("--report-chars=fE", "fE"), - ("-rA", "A"), - ("--report-chars=A", "A"), - ("-rfs", "fs"), - ("--report-chars=fs", "fs"), - ], - ) + @pytest.mark.parametrize("flag", ("-r", "--report-chars=")) + @pytest.mark.parametrize("value", ("fE", "A", "fs")) def test_report_chars_option( self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch, - opts: str, - expected: str, + flag: str, + value: str, ) -> None: """Test that -r/--report-chars is parsed correctly.""" - monkeypatch.setenv("PYTEST_ADDOPTS", opts) + monkeypatch.setenv("PYTEST_ADDOPTS", flag + value) config = pytester.parseconfig(tmp_path) - assert config.option.reportchars == expected + assert config.option.reportchars == value def test_tox_ini_wrong_version(self, pytester: Pytester) -> None: pytester.makefile(