Repository: pytest-dev/pytest
File: testing/test_config.py (Python)

Code before:
    def test_append_parse_args(
        self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch
    ) -> None:
        monkeypatch.setenv("PYTEST_ADDOPTS", '--color no -rs --tb="short"')
        tmp_path.joinpath("pytest.ini").write_text(
            textwrap.dedent(
                """\
                [pytest]
                addopts = --verbose
                """
            ),
            encoding="utf-8",
        )
        config = pytester.parseconfig(tmp_path)
        assert config.option.color == "no"
        assert config.option.reportchars == "s"
        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",
            tox="""
            [pytest]
            minversion=999.0
        """,
        )
        result = pytester.runpytest()
        assert result.ret != 0
        result.stderr.fnmatch_lines(
            ["*tox.ini: 'minversion' requires pytest-999.0, actual pytest-*"]
        )

    @pytest.mark.parametrize(
        "section, name",
        [
            ("tool:pytest", "setup.cfg"),
            ("pytest", "tox.ini"),
            ("pytest", "pytest.ini"),
            ("pytest", ".pytest.ini"),
        ],
    )
    def test_ini_names(self, pytester: Pytester, name, section) -> None:

Review comment (suggestion):
there's no suitable test for `-r` that can be parametrized? If not we could at least parametrize this one to test both the short and long version

Code after:
    def test_append_parse_args(
        self, pytester: Pytester, tmp_path: Path, monkeypatch: MonkeyPatch
    ) -> None:
        monkeypatch.setenv("PYTEST_ADDOPTS", '--color no -rs --tb="short"')
        tmp_path.joinpath("pytest.ini").write_text(
            textwrap.dedent(
                """\
                [pytest]
                addopts = --verbose
                """
            ),
            encoding="utf-8",
        )
        config = pytester.parseconfig(tmp_path)
        assert config.option.color == "no"
        assert config.option.reportchars == "s"
        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",
            tox="""
            [pytest]
            minversion=999.0
        """,
        )
        result = pytester.runpytest()
        assert result.ret != 0
        result.stderr.fnmatch_lines(
            ["*tox.ini: 'minversion' requires pytest-999.0, actual pytest-*"]
        )

    @pytest.mark.parametrize(
        "section, name",
        [