Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions docker/utils/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
corresponding to PATTERN. (It does not compile it.)
"""

import os
import re

__all__ = ["fnmatch", "fnmatchcase", "translate"]
Expand Down Expand Up @@ -39,8 +40,8 @@ def fnmatch(name, pat):
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
"""

name = name.lower()
pat = pat.lower()
name = os.path.normcase(name)
pat = os.path.normcase(pat)
return fnmatchcase(name, pat)


Expand Down
9 changes: 9 additions & 0 deletions tests/unit/utils_build_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ def test_single_filename(self):
self.all_paths - {'a.py'}
)

@pytest.mark.skipif(
IS_WINDOWS_PLATFORM, reason='Windows pattern matching folds case'
)
def test_filename_pattern_is_case_sensitive(self):
from docker.utils.build import Pattern

assert Pattern('README.md').match('README.md')
assert not Pattern('README.md').match('readme.md')

def test_single_filename_leading_dot_slash(self):
assert self.exclude(['./a.py']) == convert_paths(
self.all_paths - {'a.py'}
Expand Down