Skip to content

Commit 324ef94

Browse files
authored
Merge pull request #14024 from junhaoliao/report-chars
feat: add --report-chars long option and its corresponding test
2 parents d5757b8 + da20109 commit 324ef94

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Joseph Sawaya
237237
Josh Karpel
238238
Joshua Bronson
239239
Julian Valentin
240+
Junhao Liao
240241
Jurko Gospodnetić
241242
Justice Ndou
242243
Justyna Janczyszyn

changelog/14023.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `--report-chars` long CLI option.

doc/en/reference/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ Output and Reporting
29102910

29112911
Set verbosity level explicitly. Default: 0.
29122912

2913-
.. option:: -r CHARS
2913+
.. option:: -r CHARS, --report-chars=CHARS
29142914

29152915
Show extra test summary info as specified by chars:
29162916

src/_pytest/terminal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def pytest_addoption(parser: Parser) -> None:
189189
)
190190
group._addoption( # private to use reserved lower-case short option
191191
"-r",
192+
"--report-chars",
192193
action="store",
193194
dest="reportchars",
194195
default=_REPORTCHARS_DEFAULT,

testing/test_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ def test_append_parse_args(
9797
assert config.option.tbstyle == "short"
9898
assert config.option.verbose
9999

100+
@pytest.mark.parametrize("flag", ("-r", "--report-chars="))
101+
@pytest.mark.parametrize("value", ("fE", "A", "fs"))
102+
def test_report_chars_option(
103+
self,
104+
pytester: Pytester,
105+
tmp_path: Path,
106+
monkeypatch: MonkeyPatch,
107+
flag: str,
108+
value: str,
109+
) -> None:
110+
"""Test that -r/--report-chars is parsed correctly."""
111+
monkeypatch.setenv("PYTEST_ADDOPTS", flag + value)
112+
config = pytester.parseconfig(tmp_path)
113+
assert config.option.reportchars == value
114+
100115
def test_tox_ini_wrong_version(self, pytester: Pytester) -> None:
101116
pytester.makefile(
102117
".ini",

0 commit comments

Comments
 (0)