def test_local_plugin(pytester: Pytester, file_structure) -> None:
    """`pythonpath` kicks early enough to load plugins via -p (#11118)."""
    localplugin_py = pytester.path / "sub" / "localplugin.py"
    content = dedent(
        """
        def pytest_load_initial_conftests():
            print("local plugin load")

        def pytest_unconfigure():
            print("local plugin unconfig")
        """
    )
    localplugin_py.write_text(content, encoding="utf-8")

    pytester.makeini("[pytest]\npythonpath=sub\n")
    result = pytester.runpytest("-plocalplugin", "-s", "test_foo.py")
    result.stdout.fnmatch_lines(["local plugin load", "local plugin unconfig"])
    assert result.ret == 0
    result.assert_outcomes(passed=1)
`pythonpath` kicks early enough to load plugins via -p (#11118).
testing/test_python_path.py