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

Side by Side Diff: telemetry/telemetry/testing/serially_executed_browser_test_case.py

Issue 2660913002: [Telemetry] Makes serially_executed_browser_test_case.LoadAllTestsInModule return nothing if not ex… (Closed)
Patch Set: Created 3 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
« no previous file with comments | « telemetry/telemetry/testing/browser_test_runner.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 import inspect 5 import inspect
6 import re 6 import re
7 import unittest 7 import unittest
8 8
9 from py_utils import cloud_storage 9 from py_utils import cloud_storage
10 from telemetry.internal.browser import browser_finder 10 from telemetry.internal.browser import browser_finder
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ################################################################# 135 #################################################################
136 136
137 Args: 137 Args:
138 module: the module which contains test cases classes. 138 module: the module which contains test cases classes.
139 139
140 Returns: 140 Returns:
141 an instance of unittest.TestSuite, which contains all the tests & generated 141 an instance of unittest.TestSuite, which contains all the tests & generated
142 test cases to be run. 142 test cases to be run.
143 """ 143 """
144 suite = unittest.TestSuite() 144 suite = unittest.TestSuite()
145 finder_options = options_for_unittests.GetCopy()
146 if not hasattr(finder_options, 'browser_test_runner_running'):
147 return suite
145 for _, obj in inspect.getmembers(module): 148 for _, obj in inspect.getmembers(module):
146 if (inspect.isclass(obj) and 149 if (inspect.isclass(obj) and
147 issubclass(obj, SeriallyExecutedBrowserTestCase)): 150 issubclass(obj, SeriallyExecutedBrowserTestCase)):
148 for test in GenerateTestCases( 151 for test in GenerateTestCases(
149 test_class=obj, finder_options=options_for_unittests.GetCopy()): 152 test_class=obj, finder_options=finder_options):
150 suite.addTest(test) 153 suite.addTest(test)
151 return suite 154 return suite
152 155
153 156
154 def _GenerateTestMethod(based_method, args): 157 def _GenerateTestMethod(based_method, args):
155 return lambda self: based_method(self, *args) 158 return lambda self: based_method(self, *args)
156 159
157 160
158 _TEST_GENERATOR_PREFIX = 'GenerateTestCases_' 161 _TEST_GENERATOR_PREFIX = 'GenerateTestCases_'
159 _INVALID_TEST_NAME_RE = re.compile(r'[^a-zA-Z0-9_]') 162 _INVALID_TEST_NAME_RE = re.compile(r'[^a-zA-Z0-9_]')
(...skipping 20 matching lines...) Expand all
180 assert hasattr(test_class, based_method_name), ( 183 assert hasattr(test_class, based_method_name), (
181 '%s is specified but based method %s does not exist' % 184 '%s is specified but based method %s does not exist' %
182 (name, based_method_name)) 185 (name, based_method_name))
183 based_method = getattr(test_class, based_method_name) 186 based_method = getattr(test_class, based_method_name)
184 for generated_test_name, args in method(finder_options): 187 for generated_test_name, args in method(finder_options):
185 _ValidateTestMethodname(generated_test_name) 188 _ValidateTestMethodname(generated_test_name)
186 setattr(test_class, generated_test_name, _GenerateTestMethod( 189 setattr(test_class, generated_test_name, _GenerateTestMethod(
187 based_method, args)) 190 based_method, args))
188 test_cases.append(test_class(generated_test_name)) 191 test_cases.append(test_class(generated_test_name))
189 return test_cases 192 return test_cases
OLDNEW
« no previous file with comments | « telemetry/telemetry/testing/browser_test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698