From 483e31f93bf6b14050572f05add922a65f59f6ac Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Fri, 25 Oct 2024 09:19:00 +1300 Subject: [PATCH] Add more tests for `usethis tool ruff` (#52) --- .pre-commit-config.yaml | 2 +- src/usethis/_integrations/pre_commit/core.py | 2 +- tests/usethis/_interface/test_tool.py | 32 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0600fee..739971a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/abravalheri/validate-pyproject - rev: "v0.21" + rev: "v0.22" hooks: - id: validate-pyproject additional_dependencies: ["validate-pyproject-schema-store[all]"] diff --git a/src/usethis/_integrations/pre_commit/core.py b/src/usethis/_integrations/pre_commit/core.py index 9c48dc0..81c7c10 100644 --- a/src/usethis/_integrations/pre_commit/core.py +++ b/src/usethis/_integrations/pre_commit/core.py @@ -13,7 +13,7 @@ additional_dependencies: ["validate-pyproject-schema-store[all]"] """ # Manually bump this version when necessary -_VALIDATEPYPROJECT_VERSION = "v0.21" +_VALIDATEPYPROJECT_VERSION = "v0.22" def add_pre_commit_config() -> None: diff --git a/tests/usethis/_interface/test_tool.py b/tests/usethis/_interface/test_tool.py index 0a8a83a..1d47327 100644 --- a/tests/usethis/_interface/test_tool.py +++ b/tests/usethis/_interface/test_tool.py @@ -405,6 +405,38 @@ def test_config_file(self, uv_init_dir: Path): # Assert assert (uv_init_dir / "pyproject.toml").read_text() == "" + def test_blank_slate(self, uv_init_dir: Path): + # Arrange + contents = (uv_init_dir / "pyproject.toml").read_text() + + # Act + with change_cwd(uv_init_dir): + _ruff(remove=True, offline=is_offline()) + + # Assert + assert (uv_init_dir / "pyproject.toml").read_text() == contents + + def test_roundtrip(self, uv_init_dir: Path): + # Arrange + contents = (uv_init_dir / "pyproject.toml").read_text() + + # Act + with change_cwd(uv_init_dir): + _ruff(offline=is_offline()) + _ruff(remove=True, offline=is_offline()) + + # Assert + assert ( + (uv_init_dir / "pyproject.toml").read_text() + == contents + + """\ + +[tool.uv] +dev-dependencies = [] + +""" + ) + class TestPytest: def test_dep(self, uv_init_dir: Path):