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

Side by Side Diff: Lib/test/test_fnmatch.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_filecmp.py ('k') | Lib/test/test_funcattrs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, translate, filter 6 from fnmatch import fnmatch, fnmatchcase, translate, filter
7 7
8 class FnmatchTestCase(unittest.TestCase): 8 class FnmatchTestCase(unittest.TestCase):
9 9
10 def check_match(self, filename, pattern, should_match=1, fn=fnmatch): 10 def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
11 if should_match: 11 if should_match:
12 self.assertTrue(fn(filename, pattern), 12 self.assertTrue(fn(filename, pattern),
13 "expected %r to match pattern %r" 13 "expected %r to match pattern %r"
14 % (filename, pattern)) 14 % (filename, pattern))
15 else: 15 else:
16 self.assertTrue(not fn(filename, pattern), 16 self.assertFalse(fn(filename, pattern),
17 "expected %r not to match pattern %r" 17 "expected %r not to match pattern %r"
18 % (filename, pattern)) 18 % (filename, pattern))
19 19
20 def test_fnmatch(self): 20 def test_fnmatch(self):
21 check = self.check_match 21 check = self.check_match
22 check('abc', 'abc') 22 check('abc', 'abc')
23 check('abc', '?*?') 23 check('abc', '?*?')
24 check('abc', '???*') 24 check('abc', '???*')
25 check('abc', '*???') 25 check('abc', '*???')
26 check('abc', '???') 26 check('abc', '???')
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 81
82 def test_main(): 82 def test_main():
83 support.run_unittest(FnmatchTestCase, 83 support.run_unittest(FnmatchTestCase,
84 TranslateTestCase, 84 TranslateTestCase,
85 FilterTestCase) 85 FilterTestCase)
86 86
87 87
88 if __name__ == "__main__": 88 if __name__ == "__main__":
89 test_main() 89 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_filecmp.py ('k') | Lib/test/test_funcattrs.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+