Skip to content

Commit

Permalink
fixup! refactor(utils/decorators): rewrite remove task decorator to u…
Browse files Browse the repository at this point in the history
…se ast
  • Loading branch information
josix committed Feb 6, 2025
1 parent 0f2a9bd commit 31868ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_should_create_virtualenv_with_extra_packages_uv(self, mock_execute_in_s
ids=["without_parens", "parens", "with_args", "nested_without_parens", "nested_with_parens"],
)
def test_remove_task_decorator(self, decorators: list[str], expected_decorators: list[str]):
decorator = "\n".join(decorators)
concated_decorators = "\n".join(decorators)
expected_decorator = "\n".join(expected_decorators)
SCRIPT = dedent(
"""
Expand All @@ -213,8 +213,8 @@ def f():
import funcsigs
"""
)
py_source = f"{decorator}{SCRIPT}"
expected_source = f"{expected_decorator}{SCRIPT}" if expected_decorator else SCRIPT.lstrip()
py_source = concated_decorators + SCRIPT
expected_source = expected_decorator + SCRIPT if expected_decorator else SCRIPT.lstrip()

res = remove_task_decorator(python_source=py_source, task_decorator_name="@task.virtualenv")
assert res == expected_source
4 changes: 2 additions & 2 deletions tests/utils/test_preexisting_python_virtualenv_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class TestExternalPythonDecorator:
ids=["without_parens", "parens", "with_args", "nested_without_parens", "nested_with_parens"],
)
def test_remove_task_decorator(self, decorators: list[str], expected_decorators: list[str]):
decorator = "\n".join(decorators)
concated_decorators = "\n".join(decorators)
expected_decorator = "\n".join(expected_decorators)
SCRIPT = dedent(
"""
def f():
import funcsigs
"""
)
py_source = decorator + SCRIPT
py_source = concated_decorators + SCRIPT
expected_source = expected_decorator + SCRIPT if expected_decorator else SCRIPT.lstrip()

res = remove_task_decorator(python_source=py_source, task_decorator_name="@task.external_python")
Expand Down

0 comments on commit 31868ea

Please sign in to comment.