Skip to content

Commit

Permalink
Test interaction between --force-exclude and symlinks as cli parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sth committed Oct 27, 2023
1 parent c369e44 commit ab810bd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_black.py
Expand Up @@ -1409,6 +1409,24 @@ def test_invalid_cli_regex(self) -> None:
for option in ["--include", "--exclude", "--extend-exclude", "--force-exclude"]:
self.invokeBlack(["-", option, "**()(!!*)"], exit_code=2)

def test_force_exclude_symlink_parameter(self) -> None:
with TemporaryDirectory() as workspace:
root = Path(workspace)
(root / "pyproject.toml").touch()

symlink_target = root / "target.py"
symlink_target.write_text("print ( )\n", encoding="utf-8")

symlink = root / "symlink.py"
symlink.symlink_to(symlink_target)

# target.py would need to be reformatted, and symlink.py points to
# it, but since we force-exclude symlink.py, black should not check
# the pointed-to file.
self.invokeBlack(
["--check", r"--force-exclude=sym", str(symlink)], exit_code=0
)

def test_required_version_matches_version(self) -> None:
self.invokeBlack(
["--required-version", black.__version__, "-c", "0"],
Expand Down

0 comments on commit ab810bd

Please sign in to comment.