Skip to content

Commit 65856a6

Browse files
committed
gh-XXXXX: Improve test coverage for fnmatch.filter and fnmatch.filterfalse
1 parent 2423814 commit 65856a6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎Lib/test/test_fnmatch.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Test cases for the fnmatch module."""
22

33
import os
4+
import posixpath
45
import string
56
import unittest
67
import warnings
78
from fnmatch import fnmatch, fnmatchcase, translate, filter, filterfalse
9+
from unittest.mock import patch
810

911

1012
IGNORECASE = os.path.normcase('P') == os.path.normcase('p')
@@ -340,6 +342,11 @@ def test_sep(self):
340342
self.assertEqual(filter(['usr/bin', 'usr', 'usr\\lib'], 'usr\\*'),
341343
['usr/bin', 'usr\\lib'] if NORMSEP else ['usr\\lib'])
342344

345+
def test_posixpath(self):
346+
with patch('fnmatch.os.path', posixpath):
347+
self.assertEqual(filter(['file.txt', 'FILE.TXT'], '*.txt'), ['file.txt'])
348+
self.assertEqual(filter([b'file.txt', b'FILE.TXT'], b'*.txt'), [b'file.txt'])
349+
343350

344351
class FilterFalseTestCase(unittest.TestCase):
345352

@@ -365,6 +372,11 @@ def test_sep(self):
365372
self.assertEqual(filterfalse(['usr/bin', 'usr', 'usr\\lib'], 'usr\\*'),
366373
['usr'] if NORMSEP else ['usr/bin', 'usr'])
367374

375+
def test_posixpath(self):
376+
with patch('fnmatch.os.path', posixpath):
377+
self.assertEqual(filterfalse(['file.txt', 'FILE.TXT'], '*.txt'), ['FILE.TXT'])
378+
self.assertEqual(filterfalse([b'file.txt', b'FILE.TXT'], b'*.txt'), [b'FILE.TXT'])
379+
368380

369381
if __name__ == "__main__":
370382
unittest.main()

0 commit comments

Comments
 (0)