Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plugin get directory from poetry #211

Merged
merged 3 commits into from
Apr 13, 2024
Merged
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
6 changes: 5 additions & 1 deletion poethepoet/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def get_poe(cls, application: Application, io: IO):
except: # noqa: E722
poetry_env_path = None

cwd = Path().resolve()
# Get the cwd from poetry to ensure '--directory subdir' usage
try:
cwd = application.poetry.pyproject_path
except AttributeError:
cwd = Path().resolve()
config = PoeConfig(cwd=cwd)

if io.output.is_quiet():
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def run_poetry(args: List[str], cwd: str, env: Optional[Dict[str, str]] = None):
venv_location,
[
".[poetry_plugin]",
"./tests/fixtures/packages/poetry-1.2.1-py3-none-any.whl",
"./tests/fixtures/packages/poetry-1.8.2-py3-none-any.whl",
],
require_empty=True,
):
Expand Down
Binary file not shown.
Binary file not shown.
37 changes: 37 additions & 0 deletions tests/test_poetry_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,40 @@ def test_running_poetry_command_with_hooks(run_poetry, projects):
assert "THIS IS YOUR ENV!" in result.stdout
assert "THAT WAS YOUR ENV!" in result.stdout
# assert result.stderr == ""


@pytest.mark.slow()
@pytest.mark.usefixtures("_setup_poetry_project")
def test_running_poetry_command_with_hooks_with_directory(run_poetry, projects):
result = run_poetry(
["--directory=" + str(projects["poetry_plugin"]), "env", "info"],
cwd=projects["poetry_plugin"].parent,
)
assert "THIS IS YOUR ENV!" in result.stdout
assert "THAT WAS YOUR ENV!" in result.stdout
# assert result.stderr == ""


@pytest.mark.slow()
@pytest.mark.usefixtures("_setup_poetry_project")
def test_task_with_cli_dependency_with_directory(run_poetry, projects, is_windows):
result = run_poetry(
[
"--directory=" + str(projects["poetry_plugin"]),
"poe",
"cow-greet",
"yo yo yo",
],
cwd=projects["poetry_plugin"].parent,
)
if is_windows:
assert result.stdout.startswith("Poe => cowpy 'yo yo yo'")
assert "< yo yo yo >" in result.stdout
else:
# On POSIX cowpy expects notices its being called as a subprocess and tries
# unproductively to take input from stdin
assert result.stdout.startswith("Poe => cowpy 'yo yo yo'")
assert (
"< Cowacter, eyes:default, tongue:False, thoughts:False >" in result.stdout
)
# assert result.stderr == ""
Loading