Skip to content

Fix fnmatch filtering when simulating Windows - #1352

Open
sricharanreddycheruku wants to merge 1 commit into
pytest-dev:mainfrom
sricharanreddycheruku:agent2-python-fnmatch-windows-simulation
Open

sricharanreddycheruku wants to merge 1 commit into
pytest-dev:mainfrom
sricharanreddycheruku:agent2-python-fnmatch-windows-simulation

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

Describe the changes

When simulating Windows on a POSIX host, fnmatch.filter misses uppercase filenames such as B.TXT for *.txt. This also affects glob.glob.

fnmatch.filter skips normalizing filenames when os.path is posixpath. The patcher replaces both references with the fake path module, enabling that shortcut even when the fake filesystem uses Windows case rules. Keep fnmatch.posixpath unchanged so filtering uses the fake os.path.normcase instead.

Add regressions for string and byte patterns, case-insensitive globbing, and case-sensitive Linux matching, plus a release-note entry.

Fixes #1345.

Validation:

  • The new Windows-simulation regressions fail on Linux before the fix and pass afterward.
  • Linux / Python 3.12: python -m pyfakefs.tests.all_tests — 2,415 tests run, OK (976 skipped, 2 expected failures).
  • Linux / Python 3.12: python -m pytest pyfakefs/pytest_tests/pytest_plugin_test.py -q — 10 passed.
  • Linux and Windows: python -m unittest pyfakefs.tests.fake_filesystem_glob_test — 12 passed on each host.
  • All configured pre-commit hooks passed for the changed files, including Ruff and mypy.
  • Windows / Python 3.13: the full suite has two failures (FakePathModuleTest.test_realpath_allow_missing and SkipPathlibTest.test_exists). Repeating it with the original patcher implementation produces the same two failures.

Tasks

  • Unit tests added that reproduce the issue or prove feature is working
  • Fix or feature added
  • Entry to release notes added
  • Pre-commit CI shows no errors
  • Unit tests passing
  • For documentation changes: The Read the Docs preview builds and looks as expected

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fnmatch.filter and glob don't match uppercase names under Windows simulation

1 participant