Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Side by Side Diff: Tools/Scripts/webkitpy/thirdparty/unittest2/loader.py

Issue 20652002: Fix trailing whitespace in scripts and misc. files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't change literal diff. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 """Loading unittests.""" 1 """Loading unittests."""
2 2
3 import os 3 import os
4 import re 4 import re
5 import sys 5 import sys
6 import traceback 6 import traceback
7 import types 7 import types
8 import unittest 8 import unittest
9 9
10 from fnmatch import fnmatch 10 from fnmatch import fnmatch
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 def _make_failed_load_tests(name, exception, suiteClass): 47 def _make_failed_load_tests(name, exception, suiteClass):
48 return _make_failed_test('LoadTestsFailure', name, exception, suiteClass) 48 return _make_failed_test('LoadTestsFailure', name, exception, suiteClass)
49 49
50 def _make_failed_test(classname, methodname, exception, suiteClass): 50 def _make_failed_test(classname, methodname, exception, suiteClass):
51 def testFailure(self): 51 def testFailure(self):
52 raise exception 52 raise exception
53 attrs = {methodname: testFailure} 53 attrs = {methodname: testFailure}
54 TestClass = type(classname, (case.TestCase,), attrs) 54 TestClass = type(classname, (case.TestCase,), attrs)
55 return suiteClass((TestClass(methodname),)) 55 return suiteClass((TestClass(methodname),))
56 56
57 57
58 class TestLoader(unittest.TestLoader): 58 class TestLoader(unittest.TestLoader):
59 """ 59 """
60 This class is responsible for loading tests according to various criteria 60 This class is responsible for loading tests according to various criteria
61 and returning them wrapped in a TestSuite 61 and returning them wrapped in a TestSuite
62 """ 62 """
63 testMethodPrefix = 'test' 63 testMethodPrefix = 'test'
64 sortTestMethodsUsing = cmp 64 sortTestMethodsUsing = cmp
65 suiteClass = suite.TestSuite 65 suiteClass = suite.TestSuite
66 _top_level_dir = None 66 _top_level_dir = None
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 name = _relpath.replace(os.path.sep, '.') 234 name = _relpath.replace(os.path.sep, '.')
235 return name 235 return name
236 236
237 def _get_module_from_name(self, name): 237 def _get_module_from_name(self, name):
238 __import__(name) 238 __import__(name)
239 return sys.modules[name] 239 return sys.modules[name]
240 240
241 def _match_path(self, path, full_path, pattern): 241 def _match_path(self, path, full_path, pattern):
242 # override this method to use alternative matching strategy 242 # override this method to use alternative matching strategy
243 return fnmatch(path, pattern) 243 return fnmatch(path, pattern)
244 244
245 def _find_tests(self, start_dir, pattern): 245 def _find_tests(self, start_dir, pattern):
246 """Used by discovery. Yields test suites it loads.""" 246 """Used by discovery. Yields test suites it loads."""
247 paths = os.listdir(start_dir) 247 paths = os.listdir(start_dir)
248 248
249 for path in paths: 249 for path in paths:
250 full_path = os.path.join(start_dir, path) 250 full_path = os.path.join(start_dir, path)
251 if os.path.isfile(full_path): 251 if os.path.isfile(full_path):
252 if not VALID_MODULE_NAME.match(path): 252 if not VALID_MODULE_NAME.match(path):
253 # valid Python identifiers only 253 # valid Python identifiers only
254 continue 254 continue
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp): 313 def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
314 return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass) 314 return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
315 315
316 def makeSuite(testCaseClass, prefix='test', sortUsing=cmp, 316 def makeSuite(testCaseClass, prefix='test', sortUsing=cmp,
317 suiteClass=suite.TestSuite): 317 suiteClass=suite.TestSuite):
318 return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(test CaseClass) 318 return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(test CaseClass)
319 319
320 def findTestCases(module, prefix='test', sortUsing=cmp, 320 def findTestCases(module, prefix='test', sortUsing=cmp,
321 suiteClass=suite.TestSuite): 321 suiteClass=suite.TestSuite):
322 return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module ) 322 return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module )
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/thirdparty/unittest2/compatibility.py ('k') | Tools/Scripts/webkitpy/thirdparty/unittest2/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698