Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
- {pull}`707` drops support for Python 3.9 as it has reached end of life.
- {pull}`708` updates mypy and fixes type issues.
- {pull}`709` add uv pre-commit check.
- {pull}`713` removes uv as a test dependency. Closes {issue}`712`. Thanks to {user}`erooke`!

## 0.5.5 - 2025-07-25

Expand Down
6 changes: 3 additions & 3 deletions tests/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def task_show_capture():
"""
tmp_path.joinpath("workflow.py").write_text(textwrap.dedent(source))

result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path)
result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path)

assert result.exit_code == ExitCode.FAILED

Expand Down Expand Up @@ -128,7 +128,7 @@ def test_wrong_capture_method(tmp_path):
"""
tmp_path.joinpath("workflow.py").write_text(textwrap.dedent(source))

result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path)
result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path)
assert result.exit_code == ExitCode.CONFIGURATION_FAILED
assert "Value 'a' is not a valid" in result.stdout
assert "Traceback" not in result.stdout
Expand Down Expand Up @@ -255,7 +255,7 @@ def task_unicode():
tmp_path.joinpath("workflow.py").write_text(
textwrap.dedent(source), encoding="utf-8"
)
result = run_in_subprocess(("uv", "run", "python", "workflow.py"), cwd=tmp_path)
result = run_in_subprocess((sys.executable, "workflow.py"), cwd=tmp_path)
assert result.exit_code == ExitCode.OK
assert "1 Succeeded" in result.stdout

Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_paths_are_relative_to_configuration_file(tmp_path):
session = build(paths=[Path("src")])
"""
tmp_path.joinpath("script.py").write_text(textwrap.dedent(source))
result = run_in_subprocess(("uv", "run", "python", "script.py"), cwd=tmp_path)
result = run_in_subprocess((sys.executable, "script.py"), cwd=tmp_path)
assert result.exit_code == ExitCode.OK
assert "1 Succeeded" in result.stdout

Expand Down
2 changes: 1 addition & 1 deletion tests/test_dag_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main():
tmp_path.joinpath("input.txt").touch()

result = subprocess.run(
("uv", "run", "python", "task_example.py"),
(sys.executable, "task_example.py"),
cwd=tmp_path,
check=True,
capture_output=True,
Expand Down
8 changes: 3 additions & 5 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

def test_python_m_pytask(tmp_path):
tmp_path.joinpath("task_module.py").write_text("def task_example(): pass")
result = run_in_subprocess(
("uv", "run", "python", "-m", "pytask", tmp_path.as_posix())
)
result = run_in_subprocess((sys.executable, "-m", "pytask", tmp_path.as_posix()))
assert result.exit_code == ExitCode.OK


Expand Down Expand Up @@ -602,7 +600,7 @@ def create_file(
"""
tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source))
result = subprocess.run(
("uv", "run", "python", tmp_path.joinpath("task_module.py").as_posix()),
(sys.executable, tmp_path.joinpath("task_module.py").as_posix()),
check=False,
)
assert result.returncode == ExitCode.OK
Expand Down Expand Up @@ -632,7 +630,7 @@ def task2() -> None: pass
"""
tmp_path.joinpath("task_module.py").write_text(textwrap.dedent(source))
result = run_in_subprocess(
("uv", "run", "python", tmp_path.joinpath("task_module.py").as_posix())
(sys.executable, tmp_path.joinpath("task_module.py").as_posix())
)
assert result.exit_code == ExitCode.OK

Expand Down
57 changes: 16 additions & 41 deletions tests/test_hook_module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import subprocess
import sys
import textwrap

import pytest
Expand All @@ -9,8 +10,8 @@
from tests.conftest import run_in_subprocess


@pytest.mark.parametrize("module_name", [True, False])
def test_add_new_hook_via_cli(tmp_path, module_name):
@pytest.mark.parametrize("hook_location", ["hooks/hooks.py", "hooks.hooks"])
def test_add_new_hook_via_cli(tmp_path, hook_location):
hooks = """
import click
from pytask import hookimpl
Expand All @@ -23,38 +24,24 @@ def pytask_extend_command_line_interface(cli):
tmp_path.joinpath("hooks").mkdir()
tmp_path.joinpath("hooks", "hooks.py").write_text(textwrap.dedent(hooks))

if module_name:
args = (
"uv",
"run",
"python",
"-m",
"pytask",
"build",
"--hook-module",
"hooks.hooks",
"--help",
)
else:
args = (
"uv",
"run",
"pytask",
"build",
"--hook-module",
"hooks/hooks.py",
"--help",
)

args = (
sys.executable,
"-m",
"pytask",
"build",
"--hook-module",
hook_location,
"--help",
)
result = run_in_subprocess(args, cwd=tmp_path)
assert result.exit_code == ExitCode.OK
assert "--new-option" in result.stdout


@pytest.mark.parametrize("module_name", [True, False])
def test_add_new_hook_via_config(tmp_path, module_name):
@pytest.mark.parametrize("hook_location", ["hooks/hooks.py", "hooks.hooks"])
def test_add_new_hook_via_config(tmp_path, hook_location):
tmp_path.joinpath("pyproject.toml").write_text(
"[tool.pytask.ini_options]\nhook_module = ['hooks/hooks.py']"
f"[tool.pytask.ini_options]\nhook_module = ['{hook_location}']"
)

hooks = """
Expand All @@ -68,19 +55,7 @@ def pytask_extend_command_line_interface(cli):
tmp_path.joinpath("hooks").mkdir()
tmp_path.joinpath("hooks", "hooks.py").write_text(textwrap.dedent(hooks))

if module_name:
args = (
"uv",
"run",
"--no-project",
"python",
"-m",
"pytask",
"build",
"--help",
)
else:
args = ("uv", "run", "--no-project", "pytask", "build", "--help")
args = (sys.executable, "-m", "pytask", "build", "--help")

result = run_in_subprocess(args, cwd=tmp_path)
assert result.exit_code == ExitCode.OK
Expand Down
2 changes: 1 addition & 1 deletion tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def task_second():
tmp_path.joinpath("task_example.py").write_text(textwrap.dedent(source))

result = subprocess.run(
("uv", "run", "python", "task_example.py"),
(sys.executable, "task_example.py"),
cwd=tmp_path,
capture_output=True,
check=False,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_warnings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
import textwrap

import pytest
Expand Down Expand Up @@ -148,7 +149,7 @@ def warn_now():
path_to_warn_module.write_text(textwrap.dedent(warn_module))

# Cannot use runner since then warnings are not ignored by default.
result = run_in_subprocess(("uv", "run", "pytask"), cwd=tmp_path)
result = run_in_subprocess((sys.executable, "-m", "pytask"), cwd=tmp_path)
assert result.exit_code == ExitCode.OK
assert "Warnings" not in result.stdout
assert "warning!!!" not in result.stdout
Expand Down