def test_detect_venv(
    projects,
    run_poe_subproc,
    install_into_virtualenv,
    with_virtualenv_and_venv,
    is_windows,
):
    """
    If no executor is specified and no poetry config is present but a local venv is
    found then use it!
    """
    venv_path = projects["simple"].joinpath("venv")
    for _ in with_virtualenv_and_venv(venv_path):
        result = run_poe_subproc("detect_poe_test_package", project="simple")
        assert result.capture == "Poe => detect_poe_test_package\n"
        assert result.stdout == "No poe_test_package found\n"
        assert result.stderr == ""

        # if we install poe_test_package into this virtualenv then we should get a
        # different result
        install_into_virtualenv(
            venv_path, ("./tests/fixtures/packages/poe_test_package",)
        )
        result = run_poe_subproc("detect_poe_test_package", project="simple")
        assert result.capture == "Poe => detect_poe_test_package\n"
        assert result.stdout.startswith("poe_test_package found at ")
        if is_windows:
            assert result.stdout.endswith(
                (
                    "\\tests\\fixtures\\simple_project\\venv\\lib\\site-packages"
                    "\\poe_test_package\\__init__.py\n",
                    # Lib has a captital with python >=11
                    "\\tests\\fixtures\\simple_project\\venv\\Lib\\site-packages"
                    "\\poe_test_package\\__init__.py\n",
                )
            )
        else:
            assert result.stdout.endswith(
                f"/tests/fixtures/simple_project/venv/lib/python{PY_V}"
                "/site-packages/poe_test_package/__init__.py\n"
            )
        assert result.stderr == ""

    If no executor is specified and no poetry config is present but a local venv is
    found then use it!
    
tests/test_executors.py