Skip to content

Commit

Permalink
Adding test case for black preview setting
Browse files Browse the repository at this point in the history
Functionality added in pull request #48, test case
suggested by @ferdynice
  • Loading branch information
peterjc committed Feb 25, 2022
1 parent de3e590 commit 4a656b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/run_tests.sh
Expand Up @@ -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."
11 changes: 11 additions & 0 deletions 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()
1 change: 1 addition & 0 deletions tests/test_changes/black_preview.txt
@@ -0,0 +1 @@
test_changes/black_preview.py:8:18: BLK100 Black would make changes.
1 change: 1 addition & 0 deletions tests/with_pyproject_toml/pyproject.toml
@@ -1,3 +1,4 @@
[tool.black]
skip-string-normalization = true
skip-magic-trailing-comma = true
preview = true

0 comments on commit 4a656b1

Please sign in to comment.