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

Code before:
                "*PytestRemovedIn10Warning: The argvalues parameter*",
            ]
        )

    def test_parametrize_iterator_class_multiple_tests(
        self, pytester: Pytester
    ) -> None:
        """Test that iterators in parametrize on a class get exhausted (deprecated)."""
        pytester.makepyfile(
            """
            import pytest

            @pytest.mark.parametrize("n", iter(range(2)))
            class Test:
                def test_1(self, n):
                    pass

                def test_2(self, n):
                    pass
            """
        )
        result = pytester.runpytest("-v", "-W", "default")
        # Iterator gets exhausted after first test, second test gets no parameters.
        # This is deprecated.
        result.assert_outcomes(passed=2, skipped=1)
        # Should see the deprecation warnings.
        result.stdout.fnmatch_lines(
            [
                "*PytestRemovedIn10Warning: The argvalues parameter*",
            ]
        )


class TestMetafuncFunctionalAuto:
    """Tests related to automatically find out the correct scope for
    parametrized tests (#1832)."""

    def test_parametrize_auto_scope(self, pytester: Pytester) -> None:
        pytester.makepyfile(
            """
            import pytest

            @pytest.fixture(scope='session', autouse=True)
            def fixture():
                return 1

            @pytest.mark.parametrize('animal', ["dog", "cat"])
            def test_1(animal):
                assert animal in ('dog', 'cat')

            @pytest.mark.parametrize('animal', ['fish'])

Review comment (suggestion):
I think this can be made more clear and resilient by testing the node ids themselves as output by `-v`.

Code after:
                "*PytestRemovedIn10Warning: Passing a non-Collection iterable*",
                "*PytestRemovedIn10Warning: Passing a non-Collection iterable*",
            ]
        )

    def test_parametrize_iterator_class_multiple_tests(
        self, pytester: Pytester
    ) -> None:
        """Test that iterators in parametrize on a class get exhausted (deprecated)."""
        pytester.makepyfile(
            """
            import pytest

            @pytest.mark.parametrize("n", iter(range(2)))
            class Test:
                def test_1(self, n):
                    pass

                def test_2(self, n):
                    pass
            """
        )
        result = pytester.runpytest("-v", "-Wdefault")
        # Iterator gets exhausted after first test, second test gets no parameters.
        # This is deprecated.
        result.assert_outcomes(passed=2, skipped=1)
        result.stdout.fnmatch_lines(
            [
                "*test_parametrize_iterator_class_multiple_tests.py::Test::test_1[[]0] PASSED*",
                "*test_parametrize_iterator_class_multiple_tests.py::Test::test_1[[]1] PASSED*",
                "*test_parametrize_iterator_class_multiple_tests.py::Test::test_2[[]NOTSET] SKIPPED*",
                "*PytestRemovedIn10Warning: Passing a non-Collection iterable*",
            ]
        )


class TestMetafuncFunctionalAuto:
    """Tests related to automatically find out the correct scope for
    parametrized tests (#1832)."""

    def test_parametrize_auto_scope(self, pytester: Pytester) -> None:
        pytester.makepyfile(
            """
            import pytest

            @pytest.fixture(scope='session', autouse=True)
            def fixture():
                return 1

            @pytest.mark.parametrize('animal', ["dog", "cat"])
            def test_1(animal):