1 """Test cases for the fnmatch module."""
7 from fnmatch
import fnmatch
, fnmatchcase
10 class FnmatchTestCase(unittest
.TestCase
):
11 def check_match(self
, filename
, pattern
, should_match
=1):
13 self
.assert_(fnmatch(filename
, pattern
),
14 "expected %r to match pattern %r"
15 % (filename
, pattern
))
17 self
.assert_(not fnmatch(filename
, pattern
),
18 "expected %r not to match pattern %r"
19 % (filename
, pattern
))
21 def test_fnmatch(self
):
22 check
= self
.check_match
29 check('abc', 'ab[cd]')
30 check('abc', 'ab[!de]')
31 check('abc', 'ab[de]', 0)
35 # these test that '\' is handled correctly in character sets;
39 check('\\', r
'[!\]', 0)
42 test_support
.run_unittest(FnmatchTestCase
)