Skip to content

Commit

Permalink
Run tasks in project_root dir by default #180 (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-n authored Nov 12, 2023
1 parent aa4e160 commit ca5a171
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion poethepoet/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self._config = config
self._is_windows = sys.platform == "win32"
self.invocation = invocation
self.inheritance = inheritance or TaskInheritance(cwd=str(config.cwd))
self.inheritance = inheritance or TaskInheritance(cwd=str(config.project_dir))

@classmethod
def from_config(
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/cwd_project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.poe.tasks.default_pwd]
cmd = "poe_test_pwd"

[tool.poe.tasks.cwd]
cmd = "poe_test_pwd"
cwd = "./subdir/foo"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_cmd_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ def test_cmd_task_with_cwd_option_env(run_poe_subproc, poe_project_path):
assert result.stderr == ""


def test_cmd_task_runs_in_project_root_by_default(
run_poe_subproc, poe_project_path, projects
):
result = run_poe_subproc(
"default_pwd",
project="cwd",
cwd=poe_project_path.joinpath(
"tests", "fixtures", "cwd_project", "subdir", "foo"
),
)
assert result.capture == "Poe => poe_test_pwd\n"
assert result.stdout == f"{projects['cwd']}\n"
assert result.stderr == ""


def test_cmd_task_with_cwd_option_pwd(run_poe_subproc, poe_project_path):
result = run_poe_subproc(
"cwd_poe_pwd",
Expand Down

0 comments on commit ca5a171

Please sign in to comment.