Skip to content

Commit c116ac0

Browse files
committed
test: parameterize report-chars option parsing to cover short and long forms with various values.
1 parent 12bd5ae commit c116ac0

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

testing/test_config.py

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

100-
def test_report_chars_long_option(
101-
self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch
100+
@pytest.mark.parametrize(
101+
"opts, expected",
102+
[
103+
("-rfE", "fE"),
104+
("--report-chars=fE", "fE"),
105+
("-rA", "A"),
106+
("--report-chars=A", "A"),
107+
("-rfs", "fs"),
108+
("--report-chars=fs", "fs"),
109+
],
110+
)
111+
def test_report_chars_option(
112+
self,
113+
pytester: Pytester,
114+
tmp_path: Path,
115+
monkeypatch: MonkeyPatch,
116+
opts: str,
117+
expected: str,
102118
) -> None:
103-
"""Test that --report-chars is parsed correctly."""
104-
monkeypatch.setenv("PYTEST_ADDOPTS", "--report-chars=fE")
119+
"""Test that -r/--report-chars is parsed correctly."""
120+
monkeypatch.setenv("PYTEST_ADDOPTS", opts)
105121
config = pytester.parseconfig(tmp_path)
106-
assert config.option.reportchars == "fE"
122+
assert config.option.reportchars == expected
107123

108124
def test_tox_ini_wrong_version(self, pytester: Pytester) -> None:
109125
pytester.makefile(

0 commit comments

Comments
 (0)