Skip to content

Commit

Permalink
Adding test case for skip-magic-trailing-comma
Browse files Browse the repository at this point in the history
Functionality added in pull request #48
  • Loading branch information
peterjc committed Feb 25, 2022
1 parent 938c821 commit de3e590
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/run_tests.sh
Expand Up @@ -42,4 +42,9 @@ diff test_changes/hello_world_EOF.txt <(flake8 --select BLK test_changes/hello_w
diff with_bad_toml/hello_world.txt <(flake8 --select BLK with_bad_toml/hello_world.py)
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
# 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)

echo "Tests passed."
24 changes: 24 additions & 0 deletions tests/test_changes/commas.py
@@ -0,0 +1,24 @@
"""Example of black and magic commas."""

vegetables = {
"carrot",
"parsnip",
"potato",
"swede",
"leak",
"aubergine",
"tomato",
"peas",
"beans",
}

# This set would easily fit on one line, but a trailing comma
# after the final entry tells black (by default) to leave this
# with one entry per line:
yucky = {
"aubergine",
"squid",
"snails",
}

print("I dislike these vegetables: %s." % ", ".join(vegetables.intersection(yucky)))
1 change: 1 addition & 0 deletions tests/with_pyproject_toml/pyproject.toml
@@ -1,2 +1,3 @@
[tool.black]
skip-string-normalization = true
skip-magic-trailing-comma = true

0 comments on commit de3e590

Please sign in to comment.