def test_plugin_loading_order(pytester: Pytester) -> None:
    """Test order of plugin loading with `-p`."""
    p1 = pytester.makepyfile(
        """
        def test_terminal_plugin(request):
            import myplugin
            assert myplugin.terminal_plugin == [False, True]
        """,
        myplugin="""
            terminal_plugin = []

            def pytest_configure(config):
                terminal_plugin.append(bool(config.pluginmanager.get_plugin("terminalreporter")))

            def pytest_sessionstart(session):
                config = session.config
                terminal_plugin.append(bool(config.pluginmanager.get_plugin("terminalreporter")))
            """,
    )
    pytester.syspathinsert()
    result = pytester.runpytest("-p", "myplugin", str(p1))
    assert result.ret == 0
Test order of plugin loading with `-p`.
testing/test_config.py