Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use regex where we ignore case on windows #4252

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from contextlib import contextmanager, redirect_stderr
from dataclasses import replace
from io import BytesIO
from pathlib import Path
from pathlib import Path, WindowsPath
from platform import system
from tempfile import TemporaryDirectory
from typing import (
Expand Down Expand Up @@ -2473,7 +2473,11 @@ def test_invalid_gitignore(self) -> None:
assert result.stderr_bytes is not None

gitignore = path / ".gitignore"
assert f"Could not parse {gitignore}" in result.stderr_bytes.decode()
assert re.search(
f"Could not parse {gitignore}".replace("\\", "\\\\"),
result.stderr_bytes.decode(),
re.IGNORECASE if isinstance(gitignore, WindowsPath) else 0,
)

def test_invalid_nested_gitignore(self) -> None:
path = THIS_DIR / "data" / "invalid_nested_gitignore_tests"
Expand All @@ -2485,7 +2489,11 @@ def test_invalid_nested_gitignore(self) -> None:
assert result.stderr_bytes is not None

gitignore = path / "a" / ".gitignore"
assert f"Could not parse {gitignore}" in result.stderr_bytes.decode()
assert re.search(
f"Could not parse {gitignore}".replace("\\", "\\\\"),
result.stderr_bytes.decode(),
re.IGNORECASE if isinstance(gitignore, WindowsPath) else 0,
)

def test_gitignore_that_ignores_subfolders(self) -> None:
# If gitignore with */* is in root
Expand Down
Loading