Skip to content

Commit 395855d

Browse files
added black as dev dependency
1 parent a5343fd commit 395855d

File tree

3 files changed

+70
-12
lines changed

3 files changed

+70
-12
lines changed

poetry.lock

Lines changed: 65 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ types-pexpect = "^4.9.0.20241208"
123123
types-unidiff = "^0.7.0.20240505"
124124
uv = ">=0.6.2"
125125
pre-commit = "^4.2.0"
126+
black = "^25.1.0"
126127

127128
[tool.poetry.build]
128129
script = "codeflash/update_license_version.py"

tests/test_formatter.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,10 @@ def foo():
217217

218218

219219
def _run_formatting_test(source_filename: str, should_content_change: bool):
220-
if shutil.which("ruff") is None:
221-
pytest.skip("ruff is not installed, skipping.")
220+
try:
221+
import ruff # type: ignore
222+
except ImportError:
223+
pytest.skip("ruff is not installed")
222224
with tempfile.TemporaryDirectory() as test_dir_str:
223225
test_dir = Path(test_dir_str)
224226
this_file = Path(__file__).resolve()
@@ -269,19 +271,12 @@ def _run_formatting_test(source_filename: str, should_content_change: bool):
269271
else:
270272
assert content == original, f"Expected content to remain unchanged for {source_filename}"
271273

272-
def _ruff_or_black_installed() -> bool:
273-
return shutil.which("black") is not None or shutil.which("ruff") is not None
274-
275274

276275
def test_formatting_file_with_many_diffs():
277276
"""Test that files with many formatting errors are skipped (content unchanged)."""
278-
if not _ruff_or_black_installed():
279-
pytest.skip("Neither black nor ruff is installed, skipping formatting tests.")
280277
_run_formatting_test("many_formatting_errors.py", should_content_change=False)
281278

282279

283280
def test_formatting_file_with_few_diffs():
284281
"""Test that files with few formatting errors are formatted (content changed)."""
285-
if not _ruff_or_black_installed():
286-
pytest.skip("Neither black nor ruff is installed, skipping formatting tests.")
287282
_run_formatting_test("few_formatting_errors.py", should_content_change=True)

0 commit comments

Comments
 (0)