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

Conversation

KaiSforza
Copy link
Contributor

@KaiSforza KaiSforza commented Feb 26, 2024

Description

I was just about to start testing things, and was running into failed tests on main. Both test_invalid_gitignore and test_invalid_nested_gitignore both threw errors because of the case-sensitivity of "s" in "STRING" with gitignore being c:\\... and the output having C:\\....

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 upper or lower-case portions of the path. In this change we use the regex re.IGNORECASE flag to get it to match properly. We do not do this when the gitignore path is not a pathlib.WindowsPath object.

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary? - not necessary
  • Add / update tests if necessary? - these are the tests 😅
  • Add new / update outdated documentation? - don't think any documentation is needed

Updated test output

Running pytest with args: ['-p', 'vscode_pytest', '--rootdir', 'c:\\Users\\kai\\git\\black', 'c:\\Users\\kai\\git\\black\\tests\\test_black.py::TestFileCollection::test_invalid_nested_gitignore', 'c:\\Users\\kai\\git\\black\\tests\\test_black.py::TestFileCollection::test_invalid_gitignore']
============================= test session starts =============================
platform win32 -- Python 3.11.4, pytest-8.0.2, pluggy-1.4.0
rootdir: c:\Users\kai\git\black
configfile: pyproject.toml
plugins: cov-4.1.0, xdist-3.5.0
collected 2 items

tests\test_black.py ..                                                   [100%]

============================== 2 passed in 0.14s ==============================
Finished running tests!

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.
@KaiSforza
Copy link
Contributor Author

I don't think this change will require a change in CHANGES.md.

@JelleZijlstra JelleZijlstra added the skip news Pull requests that don't need a changelog entry. label Mar 13, 2024
@JelleZijlstra JelleZijlstra merged commit 1abcffc into psf:main Mar 13, 2024
42 of 43 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
skip news Pull requests that don't need a changelog entry.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants