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 diff --git a/changelog/14023.feature.rst b/changelog/14023.feature.rst new file mode 100644 index 00000000000..5d0f07c942e --- /dev/null +++ b/changelog/14023.feature.rst @@ -0,0 +1 @@ +Added `--report-chars` long CLI option. 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: 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..44ac0ca2aa7 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -97,6 +97,21 @@ def test_append_parse_args( assert config.option.tbstyle == "short" assert config.option.verbose + @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, + flag: str, + value: str, + ) -> None: + """Test that -r/--report-chars is parsed correctly.""" + monkeypatch.setenv("PYTEST_ADDOPTS", flag + value) + config = pytester.parseconfig(tmp_path) + assert config.option.reportchars == value + def test_tox_ini_wrong_version(self, pytester: Pytester) -> None: pytester.makefile( ".ini",