From 4a656b16c84b67cabf3310442a68782b3b93e8b2 Mon Sep 17 00:00:00 2001
From: Peter Cock
Date: Fri, 25 Feb 2022 10:51:12 +0000
Subject: [PATCH] Adding test case for black preview setting
Functionality added in pull request #48, test case
suggested by @ferdynice
---
tests/run_tests.sh | 4 +++-
tests/test_changes/black_preview.py | 11 +++++++++++
tests/test_changes/black_preview.txt | 1 +
tests/with_pyproject_toml/pyproject.toml | 1 +
4 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 tests/test_changes/black_preview.py
create mode 100644 tests/test_changes/black_preview.txt
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 6d66ecd..2e57a8c 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -43,8 +43,10 @@ diff with_bad_toml/hello_world.txt <(flake8 --select BLK with_bad_toml/hello_wor
diff with_pyproject_toml/ignoring_toml.txt <(flake8 with_pyproject_toml/ --select BLK --black-config '')
# no changes by default,
-flake8 --select BLK test_changes/commas.py
+flake8 --select BLK test_changes/commas.py tests/black_preview.py
# will make changes if we ignore the magic trailing comma:
diff test_changes/commas.txt <(flake8 --select BLK test_changes/commas.py --black-config with_pyproject_toml/pyproject.toml)
+# will make changes if we enable future functionality preview mode:
+diff test_changes/black_preview.txt <(flake8 --select BLK test_changes/black_preview.py --black-config with_pyproject_toml/pyproject.toml)
echo "Tests passed."
diff --git a/tests/test_changes/black_preview.py b/tests/test_changes/black_preview.py
new file mode 100644
index 0000000..76dc121
--- /dev/null
+++ b/tests/test_changes/black_preview.py
@@ -0,0 +1,11 @@
+"""Example showing future black string reformatting."""
+
+
+def hello():
+ """Print variations on 'Hello World'."""
+ # black v22.1.0 (first stable release) does not edit string literals,
+ # so the following is untouched unless enable preview mode:
+ print("hello " "world") # noqa: ISC001
+
+
+hello()
diff --git a/tests/test_changes/black_preview.txt b/tests/test_changes/black_preview.txt
new file mode 100644
index 0000000..09d70dd
--- /dev/null
+++ b/tests/test_changes/black_preview.txt
@@ -0,0 +1 @@
+test_changes/black_preview.py:8:18: BLK100 Black would make changes.
diff --git a/tests/with_pyproject_toml/pyproject.toml b/tests/with_pyproject_toml/pyproject.toml
index da38ae0..43c04ce 100644
--- a/tests/with_pyproject_toml/pyproject.toml
+++ b/tests/with_pyproject_toml/pyproject.toml
@@ -1,3 +1,4 @@
[tool.black]
skip-string-normalization = true
skip-magic-trailing-comma = true
+preview = true