Fix test_fnmatch.

This commit is contained in:
Georg Brandl 2010-02-08 00:04:54 +00:00
parent 841e7f3ae2
commit 6eedef60a2
1 changed files with 5 additions and 5 deletions

View File

@ -7,13 +7,13 @@ from fnmatch import fnmatch, fnmatchcase
class FnmatchTestCase(unittest.TestCase): class FnmatchTestCase(unittest.TestCase):
def check_match(self, filename, pattern, should_match=1): def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
if should_match: if should_match:
self.assertTrue(fnmatch(filename, pattern), self.assertTrue(fn(filename, pattern),
"expected %r to match pattern %r" "expected %r to match pattern %r"
% (filename, pattern)) % (filename, pattern))
else: else:
self.assertTrue(not fnmatch(filename, pattern), self.assertTrue(not fn(filename, pattern),
"expected %r not to match pattern %r" "expected %r not to match pattern %r"
% (filename, pattern)) % (filename, pattern))
@ -46,8 +46,8 @@ class FnmatchTestCase(unittest.TestCase):
def test_fnmatchcase(self): def test_fnmatchcase(self):
check = self.check_match check = self.check_match
check('AbC', 'abc', 0) check('AbC', 'abc', 0, fnmatchcase)
check('abc', 'AbC', 0) check('abc', 'AbC', 0, fnmatchcase)
def test_main(): def test_main():