def test_pytester_with_doctest(pytester: Pytester) -> None:
    """Check that pytester can be used within doctests.

    It used to use `request.function`, which is `None` with doctests."""
    pytester.makepyfile(
        **{
            "sub/t-doctest.py": """
        '''
        >>> import os
        >>> pytester = getfixture("pytester")
        >>> str(pytester.makepyfile("content")).replace(os.sep, '/')
        '.../basetemp/sub.t-doctest0/sub.py'
        '''
    """,
            "sub/__init__.py": "",
        }
    )
    result = pytester.runpytest(
        "-p", "pytester", "--doctest-modules", "sub/t-doctest.py"
    )
    assert result.ret == 0
Check that pytester can be used within doctests.

    It used to use `request.function`, which is `None` with doctests.
testing/test_pytester.py