214 lines
7.6 KiB
Diff
214 lines
7.6 KiB
Diff
From df50f6c30c696d4f9121e6cd8e885a05dce39360 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?=
|
|
<meggy.calabkova@gmail.com>
|
|
Date: Fri, 7 Feb 2025 17:05:43 +0100
|
|
Subject: [PATCH 1/4] mix_stderr parameter was removed from click 8.2.0
|
|
|
|
---
|
|
tests/test_black.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index 31bc34d4b89..8fa352e3d22 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -114,7 +114,7 @@ class BlackRunner(CliRunner):
|
|
"""Make sure STDOUT and STDERR are kept separate when testing Black via its CLI."""
|
|
|
|
def __init__(self) -> None:
|
|
- super().__init__(mix_stderr=False)
|
|
+ super().__init__()
|
|
|
|
|
|
def invokeBlack(
|
|
|
|
From a65eb895e13263dc700cfbf60db0376e15957c4e Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Mark=C3=A9ta=20Cal=C3=A1bkov=C3=A1?=
|
|
<meggy.calabkova@gmail.com>
|
|
Date: Mon, 10 Feb 2025 11:12:17 +0100
|
|
Subject: [PATCH 2/4] make the call conditional on click version
|
|
|
|
---
|
|
tests/test_black.py | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index 8fa352e3d22..cbb5006d070 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -14,6 +14,7 @@
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from contextlib import contextmanager, redirect_stderr
|
|
from dataclasses import fields, replace
|
|
+from importlib.metadata import version as imp_version
|
|
from io import BytesIO
|
|
from pathlib import Path, WindowsPath
|
|
from platform import system
|
|
@@ -26,6 +27,7 @@
|
|
from click import unstyle
|
|
from click.testing import CliRunner
|
|
from pathspec import PathSpec
|
|
+from packaging.version import Version
|
|
|
|
import black
|
|
import black.files
|
|
@@ -114,7 +116,10 @@ class BlackRunner(CliRunner):
|
|
"""Make sure STDOUT and STDERR are kept separate when testing Black via its CLI."""
|
|
|
|
def __init__(self) -> None:
|
|
- super().__init__()
|
|
+ if Version(imp_version('click')) >= Version('8.2.0'):
|
|
+ super().__init__()
|
|
+ else:
|
|
+ super().__init__(mix_stderr=False)
|
|
|
|
|
|
def invokeBlack(
|
|
|
|
From bdc188f550709e40b86f97777465e4068c61c261 Mon Sep 17 00:00:00 2001
|
|
From: "pre-commit-ci[bot]"
|
|
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
|
Date: Mon, 10 Feb 2025 11:02:28 +0000
|
|
Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks
|
|
|
|
for more information, see https://pre-commit.ci
|
|
---
|
|
tests/test_black.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index cbb5006d070..9870cec4c26 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -26,8 +26,8 @@
|
|
import pytest
|
|
from click import unstyle
|
|
from click.testing import CliRunner
|
|
-from pathspec import PathSpec
|
|
from packaging.version import Version
|
|
+from pathspec import PathSpec
|
|
|
|
import black
|
|
import black.files
|
|
|
|
From 3dfacb5f34476b8c1ff28b5eb05cb85ff7418a66 Mon Sep 17 00:00:00 2001
|
|
From: MeggyCal <MeggyCal@users.noreply.github.com>
|
|
Date: Mon, 17 Feb 2025 12:01:26 +0100
|
|
Subject: [PATCH 4/4] double quotes
|
|
|
|
---
|
|
tests/test_black.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index 9870cec4c26..4bdbdbba5cf 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -116,7 +116,7 @@ class BlackRunner(CliRunner):
|
|
"""Make sure STDOUT and STDERR are kept separate when testing Black via its CLI."""
|
|
|
|
def __init__(self) -> None:
|
|
- if Version(imp_version('click')) >= Version('8.2.0'):
|
|
+ if Version(imp_version("click")) >= Version("8.2.0"):
|
|
super().__init__()
|
|
else:
|
|
super().__init__(mix_stderr=False)
|
|
|
|
From 17101f151b407cb3346b0a472d9e32d7a56d5aca Mon Sep 17 00:00:00 2001
|
|
From: "Michael R. Crusoe" <michael.crusoe@gmail.com>
|
|
Date: Thu, 27 Feb 2025 15:17:21 +0100
|
|
Subject: [PATCH] additional fix for click 8.2.0
|
|
|
|
---
|
|
tests/test_black.py | 18 +++++++++---------
|
|
1 file changed, 9 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index 4bdbdbba5cf..ca19c17678b 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -192,10 +192,10 @@ def test_piping(self) -> None:
|
|
input=BytesIO(source.encode("utf-8")),
|
|
)
|
|
self.assertEqual(result.exit_code, 0)
|
|
- self.assertFormatEqual(expected, result.output)
|
|
- if source != result.output:
|
|
- black.assert_equivalent(source, result.output)
|
|
- black.assert_stable(source, result.output, DEFAULT_MODE)
|
|
+ self.assertFormatEqual(expected, result.stdout)
|
|
+ if source != result.stdout:
|
|
+ black.assert_equivalent(source, result.stdout)
|
|
+ black.assert_stable(source, result.stdout, DEFAULT_MODE)
|
|
|
|
def test_piping_diff(self) -> None:
|
|
diff_header = re.compile(
|
|
@@ -215,7 +215,7 @@ def test_piping_diff(self) -> None:
|
|
black.main, args, input=BytesIO(source.encode("utf-8"))
|
|
)
|
|
self.assertEqual(result.exit_code, 0)
|
|
- actual = diff_header.sub(DETERMINISTIC_HEADER, result.output)
|
|
+ actual = diff_header.sub(DETERMINISTIC_HEADER, result.stdout)
|
|
actual = actual.rstrip() + "\n" # the diff output has a trailing space
|
|
self.assertEqual(expected, actual)
|
|
|
|
@@ -300,7 +300,7 @@ def test_expression_diff(self) -> None:
|
|
self.assertEqual(result.exit_code, 0)
|
|
finally:
|
|
os.unlink(tmp_file)
|
|
- actual = result.output
|
|
+ actual = result.stdout
|
|
actual = diff_header.sub(DETERMINISTIC_HEADER, actual)
|
|
if expected != actual:
|
|
dump = black.dump_to_file(actual)
|
|
@@ -409,7 +409,7 @@ def test_skip_magic_trailing_comma(self) -> None:
|
|
self.assertEqual(result.exit_code, 0)
|
|
finally:
|
|
os.unlink(tmp_file)
|
|
- actual = result.output
|
|
+ actual = result.stdout
|
|
actual = diff_header.sub(DETERMINISTIC_HEADER, actual)
|
|
actual = actual.rstrip() + "\n" # the diff output has a trailing space
|
|
if expected != actual:
|
|
@@ -1831,7 +1831,7 @@ def test_bpo_2142_workaround(self) -> None:
|
|
self.assertEqual(result.exit_code, 0)
|
|
finally:
|
|
os.unlink(tmp_file)
|
|
- actual = result.output
|
|
+ actual = result.stdout
|
|
actual = diff_header.sub(DETERMINISTIC_HEADER, actual)
|
|
self.assertEqual(actual, expected)
|
|
|
|
@@ -1841,7 +1841,7 @@ def compare_results(
|
|
) -> None:
|
|
"""Helper method to test the value and exit code of a click Result."""
|
|
assert (
|
|
- result.output == expected_value
|
|
+ result.stdout == expected_value
|
|
), "The output did not match the expected value."
|
|
assert result.exit_code == expected_exit_code, "The exit code is incorrect."
|
|
|
|
|
|
From 7cf419741ab55028519f43524c3414a759aaa984 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
|
|
Date: Mon, 12 May 2025 13:49:11 +0200
|
|
Subject: [PATCH] Update test_code_option_safe to work with click 8.2.0
|
|
|
|
---
|
|
tests/test_black.py | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/tests/test_black.py b/tests/test_black.py
|
|
index acafb521619..f5c950244ef 100644
|
|
--- a/tests/test_black.py
|
|
+++ b/tests/test_black.py
|
|
@@ -1907,7 +1907,8 @@ def test_code_option_safe(self) -> None:
|
|
args = ["--safe", "--code", code]
|
|
result = CliRunner().invoke(black.main, args)
|
|
|
|
- self.compare_results(result, error_msg, 123)
|
|
+ assert error_msg == result.output
|
|
+ assert result.exit_code == 123
|
|
|
|
def test_code_option_fast(self) -> None:
|
|
"""Test that the code option ignores errors when the sanity checks fail."""
|