Use regex where we ignore case on windows (#4252)
On windows the path `FoObAR` is the same as `foobar`, so the output of `black` on a windows machine could output the path to `.gitignore` with an upper or lower-case drive letter.
This commit is contained in:
parent
719e67462c
commit
1abcffc818
@ -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 (
|
||||
@ -2460,7 +2460,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"
|
||||
@ -2472,7 +2476,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
|
||||
|
Loading…
Reference in New Issue
Block a user