Skip to content

Commit 41ff131

Browse files
Add test for codespell integration on pre-commit removal
1 parent 61905e9 commit 41ff131

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/usethis/_integrations/pre_commit/core.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ def uninstall_pre_commit_hooks() -> None:
5151
in a git repo.
5252
"""
5353
if usethis_config.frozen:
54-
box_print(
55-
"Run 'uv run pre-commit uninstall' to deregister pre-commit with git."
56-
)
54+
box_print("Run 'uvx pre-commit uninstall' to deregister pre-commit with git.")
5755
return
5856

5957
tick_print("Ensuring pre-commit hooks are uninstalled.")

tests/usethis/_core/test_tool.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,31 @@ def test_pyproject_fmt_used(
801801
"☐ Run 'pyproject-fmt pyproject.toml' to run pyproject-fmt.\n"
802802
)
803803

804+
@pytest.mark.usefixtures("_vary_network_conn")
805+
def test_codepsell_used(
806+
self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]
807+
):
808+
with change_cwd(uv_init_dir):
809+
# Arrange
810+
with usethis_config.set(quiet=True):
811+
use_pre_commit()
812+
use_codespell()
813+
capfd.readouterr()
814+
815+
# Act
816+
use_pre_commit(remove=True)
817+
818+
# Assert
819+
out, err = capfd.readouterr()
820+
assert not err
821+
assert out == (
822+
"☐ Run 'uvx pre-commit uninstall' to deregister pre-commit with git.\n"
823+
"✔ Removing '.pre-commit-config.yaml'.\n"
824+
"✔ Removing dependency 'pre-commit' from the 'dev' group in 'pyproject.toml'.\n"
825+
"✔ Adding dependency 'codespell' to the 'dev' group in 'pyproject.toml'.\n"
826+
"☐ Run 'codespell' to run the Codespell spellchecker.\n"
827+
)
828+
804829
class TestBitbucketCIIntegration:
805830
def test_prexisting(self, uv_init_repo_dir: Path):
806831
# Arrange

0 commit comments

Comments
 (0)