Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/poetry_plugin_bundle/console/commands/bundle/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class BundleVenvCommand(BundleCommand):
bundler_name = "venv"

def configure_bundler(self, bundler: VenvBundler) -> None: # type: ignore[override]
bundler.set_path(Path(self.argument("path")))
# resolve now, so entrypoint shebangs do not depend on the current directory
bundler.set_path(Path(self.argument("path")).resolve())
bundler.set_executable(self.option("python"))
bundler.set_remove(self.option("clear"))
bundler.set_compile(self.option("compile"))
Expand Down
33 changes: 28 additions & 5 deletions tests/console/commands/bundle/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


if TYPE_CHECKING:
import pytest

from cleo.testers.application_tester import ApplicationTester
from pytest_mock import MockerFixture

Expand Down Expand Up @@ -46,11 +48,11 @@ def test_venv_calls_venv_bundler(
] == mock.call_args_list

assert set_path.call_args_list == [
mocker.call(mocker.ANY, Path("/foo")),
mocker.call(mocker.ANY, Path("/foo")),
mocker.call(mocker.ANY, Path("/foo")),
mocker.call(mocker.ANY, Path("/foo")),
mocker.call(mocker.ANY, Path("/foo")),
mocker.call(mocker.ANY, Path("/foo").resolve()),
mocker.call(mocker.ANY, Path("/foo").resolve()),
mocker.call(mocker.ANY, Path("/foo").resolve()),
mocker.call(mocker.ANY, Path("/foo").resolve()),
mocker.call(mocker.ANY, Path("/foo").resolve()),
]
assert set_executable.call_args_list == [
mocker.call(mocker.ANY, None),
Expand Down Expand Up @@ -81,3 +83,24 @@ def test_venv_calls_venv_bundler(
mocker.call(mocker.ANY, False),
mocker.call(mocker.ANY, True),
]


def test_venv_resolves_relative_path(
app_tester: ApplicationTester,
mocker: MockerFixture,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
mocker.patch(
"poetry_plugin_bundle.bundlers.venv_bundler.VenvBundler.bundle",
return_value=True,
)
set_path = mocker.spy(VenvBundler, "set_path")
monkeypatch.chdir(tmp_path)

app_tester.application.catch_exceptions(False)
assert app_tester.execute("bundle venv ../bundle") == 0

assert set_path.call_args_list == [
mocker.call(mocker.ANY, (tmp_path.parent / "bundle").resolve())
]
Loading