| OLD | NEW |
| 1 """Test cases for the fnmatch module.""" | 1 """Test cases for the fnmatch module.""" |
| 2 | 2 |
| 3 from test import support | 3 from test import support |
| 4 import unittest | 4 import unittest |
| 5 | 5 |
| 6 from fnmatch import fnmatch, fnmatchcase | 6 from fnmatch import fnmatch, fnmatchcase |
| 7 | 7 |
| 8 | 8 |
| 9 class FnmatchTestCase(unittest.TestCase): | 9 class FnmatchTestCase(unittest.TestCase): |
| 10 def check_match(self, filename, pattern, should_match=1): | 10 def check_match(self, filename, pattern, should_match=1): |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 check('abc', 'ab[de]', 0) | 30 check('abc', 'ab[de]', 0) |
| 31 check('a', '??', 0) | 31 check('a', '??', 0) |
| 32 check('a', 'b', 0) | 32 check('a', 'b', 0) |
| 33 | 33 |
| 34 # these test that '\' is handled correctly in character sets; | 34 # these test that '\' is handled correctly in character sets; |
| 35 # see SF bug #??? | 35 # see SF bug #??? |
| 36 check('\\', r'[\]') | 36 check('\\', r'[\]') |
| 37 check('a', r'[!\]') | 37 check('a', r'[!\]') |
| 38 check('\\', r'[!\]', 0) | 38 check('\\', r'[!\]', 0) |
| 39 | 39 |
| 40 def test_mix_bytes_str(self): |
| 41 self.assertRaises(TypeError, fnmatch, 'test', b'*') |
| 42 self.assertRaises(TypeError, fnmatch, b'test', '*') |
| 43 self.assertRaises(TypeError, fnmatchcase, 'test', b'*') |
| 44 self.assertRaises(TypeError, fnmatchcase, b'test', '*') |
| 45 |
| 46 def test_bytes(self): |
| 47 self.check_match(b'test', b'te*') |
| 48 self.check_match(b'test\xff', b'te*\xff') |
| 40 | 49 |
| 41 def test_main(): | 50 def test_main(): |
| 42 support.run_unittest(FnmatchTestCase) | 51 support.run_unittest(FnmatchTestCase) |
| 43 | 52 |
| 44 | 53 |
| 45 if __name__ == "__main__": | 54 if __name__ == "__main__": |
| 46 test_main() | 55 test_main() |
| OLD | NEW |