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

Code before:
            @pytest.mark.parametrize('r', [re.compile(b'foo')])
            def test_stuff(r):
                pass
        """
        )
        res = pytester.runpytest(p)
        res.stdout.fnmatch_lines(["*1 passed*"])

    def test_parametrized_with_null_bytes(self, pytester: Pytester) -> None:
        """Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)"""
        p = pytester.makepyfile(
            """\
            import pytest

            @pytest.mark.parametrize("data", [b"\\x00", "\\x00", 'ação'])
            def test_foo(data):
                assert data
            """
        )
        res = pytester.runpytest(p)
        res.assert_outcomes(passed=3)

    @pytest.mark.filterwarnings("ignore:'encoding' argument not specified")
    def test_command_line_args_from_file(
        self, pytester: Pytester, tmp_path: Path
    ) -> None:
        pytester.makepyfile(
            test_file="""
            import pytest

            class TestClass:
                @pytest.mark.parametrize("a", ["x","y"])
                def test_func(self, a):
                    pass
            """
        )
        tests = [
            "test_file.py::TestClass::test_func[x]",
            "test_file.py::TestClass::test_func[y]",
        ]
        args_file = pytester.maketxtfile(tests="\n".join(tests))
        result = pytester.runpytest(f"@{args_file.absolute()}")
        result.assert_outcomes(failed=0, passed=2)


class TestInvocationVariants:
    def test_earlyinit(self, pytester: Pytester) -> None:
        p = pytester.makepyfile(
            """
            import pytest
            assert hasattr(pytest, 'mark')

Review comment (suggestion):
```suggestion
    # Warning ignore because of:
    # https://github.com/python/cpython/issues/85308
    # Can be removed once Python<3.12 support is dropped.
    @pytest.mark.filterwarnings("ignore:'encoding' argument not specified")
```

Code after:
            @pytest.mark.parametrize('r', [re.compile(b'foo')])
            def test_stuff(r):
                pass
        """
        )
        res = pytester.runpytest(p)
        res.stdout.fnmatch_lines(["*1 passed*"])

    def test_parametrized_with_null_bytes(self, pytester: Pytester) -> None:
        """Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)"""
        p = pytester.makepyfile(
            """\
            import pytest

            @pytest.mark.parametrize("data", [b"\\x00", "\\x00", 'ação'])
            def test_foo(data):
                assert data
            """
        )
        res = pytester.runpytest(p)
        res.assert_outcomes(passed=3)

    # Warning ignore because of:
    # https://github.com/python/cpython/issues/85308
    # Can be removed once Python<3.12 support is dropped.
    @pytest.mark.filterwarnings("ignore:'encoding' argument not specified")
    def test_command_line_args_from_file(
        self, pytester: Pytester, tmp_path: Path
    ) -> None:
        pytester.makepyfile(
            test_file="""
            import pytest

            class TestClass:
                @pytest.mark.parametrize("a", ["x","y"])
                def test_func(self, a):
                    pass
            """
        )
        tests = [
            "test_file.py::TestClass::test_func[x]",
            "test_file.py::TestClass::test_func[y]",
            "-q",
        ]
        args_file = pytester.maketxtfile(tests="\n".join(tests))
        result = pytester.runpytest(f"@{args_file}")
        result.assert_outcomes(failed=0, passed=2)


class TestInvocationVariants:
    def test_earlyinit(self, pytester: Pytester) -> None: