Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Delta Between Two Patch Sets: Lib/test/test_fnmatch.py

Issue 3055: combined patches from http://bugs.python.org/issue3187 (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Left Patch Set: Created 1 year, 2 months ago
Right Patch Set: One more tweak (fold some long lines) Created 1 year, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 import sys
6 5
7 from fnmatch import fnmatch, fnmatchcase, filter 6 from fnmatch import fnmatch, fnmatchcase
8 7
9 8
10 class FnmatchTestCase(unittest.TestCase): 9 class FnmatchTestCase(unittest.TestCase):
11 def check_match(self, filename, pattern, should_match=1): 10 def check_match(self, filename, pattern, should_match=1):
12 if should_match: 11 if should_match:
13 self.assert_(fnmatch(filename, pattern), 12 self.assert_(fnmatch(filename, pattern),
14 "expected %r to match pattern %r" 13 "expected %r to match pattern %r"
15 % (filename, pattern)) 14 % (filename, pattern))
16 else: 15 else:
17 self.assert_(not fnmatch(filename, pattern), 16 self.assert_(not fnmatch(filename, pattern),
(...skipping 13 matching lines...) Expand all
31 check('abc', 'ab[de]', 0) 30 check('abc', 'ab[de]', 0)
32 check('a', '??', 0) 31 check('a', '??', 0)
33 check('a', 'b', 0) 32 check('a', 'b', 0)
34 33
35 # these test that '\' is handled correctly in character sets; 34 # these test that '\' is handled correctly in character sets;
36 # see SF bug #??? 35 # see SF bug #???
37 check('\\', r'[\]') 36 check('\\', r'[\]')
38 check('a', r'[!\]') 37 check('a', r'[!\]')
39 check('\\', r'[!\]', 0) 38 check('\\', r'[!\]', 0)
40 39
41 def test_filter_bytes(self): 40 def test_mix_bytes_str(self):
42 charset = sys.getfilesystemencoding() 41 self.assertRaises(TypeError, fnmatch, 'test', b'*')
43 abc = "abc".encode(charset) 42 self.assertRaises(TypeError, fnmatch, b'test', '*')
44 names = ["abc", abc] 43 self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
45 self.assertEqual(filter(names, "*"), names) 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')
46 49
47 def test_main(): 50 def test_main():
48 support.run_unittest(FnmatchTestCase) 51 support.run_unittest(FnmatchTestCase)
49 52
50 53
51 if __name__ == "__main__": 54 if __name__ == "__main__":
52 test_main() 55 test_main()
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r483