def test_auto_use_defined_in_same_module(
        self, pytester: Pytester, scope: str
    ) -> None:
        """Autouse fixtures defined in the same module as the doctest get picked
        up properly.

        Regression test for #11929.
        """
        pytester.makepyfile(
            f"""
            import pytest

            AUTO = "the fixture did not run"

            @pytest.fixture(autouse=True, scope="{scope}")
            def auto(request):
                global AUTO
                AUTO = "the fixture ran"

            def my_doctest():
                '''My doctest.

                >>> my_doctest()
                'the fixture ran'
                '''
                return AUTO
            """
        )
        result = pytester.runpytest("--doctest-modules")
        result.assert_outcomes(passed=1)
Autouse fixtures defined in the same module as the doctest get picked
        up properly.

        Regression test for #11929.
        
testing/test_doctest.py