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
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ ALWAYS check whether an existing function already covers your use case before im
- `get_project_name_from_dir()` (`usethis._file.dir`) — Derive a valid project name from the current directory name.
- `deep_merge()` (`usethis._file.merge`) — Recursively merge source into target in place, returning target.
- `print_keys()` (`usethis._file.print_`) — Convert a list of keys to a string.
- `get_project_deps()` (`usethis._file.pyproject_toml.deps`) — Get all project dependencies from [project.dependencies].
- `get_dep_groups()` (`usethis._file.pyproject_toml.deps`) — Get all dependency groups from [dependency-groups].
- `get_name()` (`usethis._file.pyproject_toml.name`) — Get the project name from pyproject.toml.
- `get_description()` (`usethis._file.pyproject_toml.name`) — Get the project description from pyproject.toml.
- `get_project_dict()` (`usethis._file.pyproject_toml.project`) — Get the contents of the [project] section from pyproject.toml.
Expand Down
2 changes: 2 additions & 0 deletions docs/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
- `get_project_name_from_dir()` (`usethis._file.dir`) — Derive a valid project name from the current directory name.
- `deep_merge()` (`usethis._file.merge`) — Recursively merge source into target in place, returning target.
- `print_keys()` (`usethis._file.print_`) — Convert a list of keys to a string.
- `get_project_deps()` (`usethis._file.pyproject_toml.deps`) — Get all project dependencies from [project.dependencies].
- `get_dep_groups()` (`usethis._file.pyproject_toml.deps`) — Get all dependency groups from [dependency-groups].
- `get_name()` (`usethis._file.pyproject_toml.name`) — Get the project name from pyproject.toml.
- `get_description()` (`usethis._file.pyproject_toml.name`) — Get the project description from pyproject.toml.
- `get_project_dict()` (`usethis._file.pyproject_toml.project`) — Get the contents of the [project] section from pyproject.toml.
Expand Down
38 changes: 26 additions & 12 deletions tests/usethis/_core/test_core_tool.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shlex
import subprocess
import unittest
import unittest.mock
Expand Down Expand Up @@ -39,10 +40,12 @@
from usethis._integrations.pre_commit.yaml import PreCommitConfigYAMLManager
from usethis._python.version import PythonVersion
from usethis._test import change_cwd
from usethis._tool.all_ import ALL_TOOLS
from usethis._tool.all_ import ALL_TOOLS, SupportedToolType
from usethis._tool.impl.base.pytest import PytestTool
from usethis._tool.impl.base.ruff import RuffTool
from usethis._types.backend import BackendEnum
from usethis._types.deps import Dependency
from usethis.errors import NoDefaultToolCommand


class TestAllHooksList:
Expand Down Expand Up @@ -128,17 +131,6 @@ def test_pre_commit_integration(
"☐ Run 'uv run codespell' to run the Codespell spellchecker."
)

@pytest.mark.usefixtures("_vary_network_conn")
def test_runs(self, uv_env_dir: Path):
# An env is needed in which to run codespell

with change_cwd(uv_env_dir), PyprojectTOMLManager():
# Arrange
use_codespell()

# Act, Assert (no errors)
call_uv_subprocess(["run", "codespell"], change_toml=False)

@pytest.mark.usefixtures("_vary_network_conn")
def test_codespell_rc_file(self, uv_init_dir: Path):
# This file is only preferred to pyproject.toml if there's already
Expand Down Expand Up @@ -3795,6 +3787,28 @@ def test_add_all_tool(self, uv_init_dir: Path):
for tool in ALL_TOOLS:
use_tool(tool)

@pytest.mark.parametrize("tool", ALL_TOOLS, ids=lambda t: t.name)
@pytest.mark.usefixtures("_vary_network_conn")
def test_runs(self, tool: SupportedToolType, uv_env_dir: Path):
with change_cwd(uv_env_dir), files_manager():
use_tool(tool)

try:
cmd = tool.raw_cmd()
except NoDefaultToolCommand:
pytest.skip(f"{tool.name} has no default command")

# pytest needs at least one test to avoid exit code 5 (no tests collected)
if isinstance(tool, PytestTool):
(uv_env_dir / "tests" / "test_placeholder.py").write_text(
"def test_placeholder(): pass\n"
)

call_uv_subprocess(
["run", *shlex.split(cmd)],
change_toml=False,
)


class TestTy:
class TestAdd:
Expand Down
Loading