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

Side by Side Diff: chrome/test/chromedriver/test/unittest_util.py

Issue 1592403002: update obsolete code.google.com documentation links (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 10 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Utilities for dealing with the python unittest module.""" 5 """Utilities for dealing with the python unittest module."""
6 6
7 import fnmatch 7 import fnmatch
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 def GetTestName(test): 87 def GetTestName(test):
88 """Gets the test name of the given unittest test.""" 88 """Gets the test name of the given unittest test."""
89 return '.'.join([test.__class__.__module__, 89 return '.'.join([test.__class__.__module__,
90 test.__class__.__name__, 90 test.__class__.__name__,
91 test._testMethodName]) 91 test._testMethodName])
92 92
93 93
94 def FilterTestSuite(suite, gtest_filter): 94 def FilterTestSuite(suite, gtest_filter):
95 """Returns a new filtered tests suite based on the given gtest filter. 95 """Returns a new filtered tests suite based on the given gtest filter.
96 96
97 See http://code.google.com/p/googletest/wiki/AdvancedGuide 97 See https://github.com/google/googletest/blob/master/googletest/docs/AdvancedG uide.md
98 for gtest_filter specification. 98 for gtest_filter specification.
99 """ 99 """
100 return unittest.TestSuite(FilterTests(GetTestsFromSuite(suite), gtest_filter)) 100 return unittest.TestSuite(FilterTests(GetTestsFromSuite(suite), gtest_filter))
101 101
102 102
103 def FilterTests(all_tests, gtest_filter): 103 def FilterTests(all_tests, gtest_filter):
104 """Returns a filtered list of tests based on the given gtest filter. 104 """Returns a filtered list of tests based on the given gtest filter.
105 105
106 See http://code.google.com/p/googletest/wiki/AdvancedGuide 106 See https://github.com/google/googletest/blob/master/googletest/docs/AdvancedG uide.md
107 for gtest_filter specification. 107 for gtest_filter specification.
108 """ 108 """
109 pattern_groups = gtest_filter.split('-') 109 pattern_groups = gtest_filter.split('-')
110 positive_patterns = pattern_groups[0].split(':') 110 positive_patterns = pattern_groups[0].split(':')
111 negative_patterns = None 111 negative_patterns = None
112 if len(pattern_groups) > 1: 112 if len(pattern_groups) > 1:
113 negative_patterns = pattern_groups[1].split(':') 113 negative_patterns = pattern_groups[1].split(':')
114 114
115 tests = [] 115 tests = []
116 for test in all_tests: 116 for test in all_tests:
117 test_name = GetTestName(test) 117 test_name = GetTestName(test)
118 # Test name must by matched by one positive pattern. 118 # Test name must by matched by one positive pattern.
119 for pattern in positive_patterns: 119 for pattern in positive_patterns:
120 if fnmatch.fnmatch(test_name, pattern): 120 if fnmatch.fnmatch(test_name, pattern):
121 break 121 break
122 else: 122 else:
123 continue 123 continue
124 # Test name must not be matched by any negative patterns. 124 # Test name must not be matched by any negative patterns.
125 for pattern in negative_patterns or []: 125 for pattern in negative_patterns or []:
126 if fnmatch.fnmatch(test_name, pattern): 126 if fnmatch.fnmatch(test_name, pattern):
127 break 127 break
128 else: 128 else:
129 tests += [test] 129 tests += [test]
130 return tests 130 return tests
OLDNEW
« no previous file with comments | « chrome/test/base/web_ui_browser_test_browsertest.cc ('k') | components/json_schema/json_schema_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698