OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os | 6 import os |
7 import re | 7 import re |
8 | 8 |
9 from collections import namedtuple | 9 from collections import namedtuple |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 assert f.fully_bound | 144 assert f.fully_bound |
145 return f.func(*f.args, **f.kwargs) | 145 return f.func(*f.args, **f.kwargs) |
146 | 146 |
147 def __repr__(self): | 147 def __repr__(self): |
148 return 'FuncCall(%r, *%r, **%r)' % (self.func, self.args, self.kwargs) | 148 return 'FuncCall(%r, *%r, **%r)' % (self.func, self.args, self.kwargs) |
149 | 149 |
150 | 150 |
151 _Test = namedtuple( | 151 _Test = namedtuple( |
152 'Test', 'name func_call expect_dir expect_base ext covers breakpoints') | 152 'Test', 'name func_call expect_dir expect_base ext covers breakpoints') |
153 | 153 |
154 class FakeTest(_Test): | |
155 """Like Test but without the hard-to-pickle stuff.""" | |
156 pass | |
tandrii(chromium)
2014/09/12 17:27:03
maybe, this:
class TestInfo(namedtuple('TestInfo'
| |
157 | |
154 class Test(_Test): | 158 class Test(_Test): |
155 TEST_COVERS_MATCH = re.compile('.*/test/([^/]*)_test\.py$') | 159 TEST_COVERS_MATCH = re.compile('.*/test/([^/]*)_test\.py$') |
156 | 160 |
157 def __new__(cls, name, func_call, expect_dir=None, expect_base=None, | 161 def __new__(cls, name, func_call, expect_dir=None, expect_base=None, |
158 ext='json', covers=None, breakpoints=None, break_funcs=()): | 162 ext='json', covers=None, breakpoints=None, break_funcs=()): |
159 """Create a new test. | 163 """Create a new test. |
160 | 164 |
161 @param name: The name of the test. Will be used as the default expect_base | 165 @param name: The name of the test. Will be used as the default expect_base |
162 | 166 |
163 @param func_call: A FuncCall object | 167 @param func_call: A FuncCall object |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 return self._replace(func_call=self.func_call.bind(*args, **kwargs)) | 246 return self._replace(func_call=self.func_call.bind(*args, **kwargs)) |
243 | 247 |
244 def restrict(self, tests): | 248 def restrict(self, tests): |
245 assert tests[0] is self | 249 assert tests[0] is self |
246 return self | 250 return self |
247 | 251 |
248 | 252 |
249 _MultiTest = namedtuple( | 253 _MultiTest = namedtuple( |
250 'MultiTest', 'name make_ctx_call destroy_ctx_call tests atomic') | 254 'MultiTest', 'name make_ctx_call destroy_ctx_call tests atomic') |
251 | 255 |
256 | |
257 class FakeMultiTest(_MultiTest): | |
dnj
2014/09/12 17:35:38
Is this used?
| |
258 """Like MultiTest, without the hard-to-pickle stuff.""" | |
259 pass | |
260 | |
261 | |
252 class MultiTest(_MultiTest): | 262 class MultiTest(_MultiTest): |
253 """A wrapper around one or more Test instances. | 263 """A wrapper around one or more Test instances. |
254 | 264 |
255 Allows the entire group to have common pre- and post- actions and an optional | 265 Allows the entire group to have common pre- and post- actions and an optional |
256 shared context between the Test methods (represented by Bind(name='context')). | 266 shared context between the Test methods (represented by Bind(name='context')). |
257 | 267 |
258 Args: | 268 Args: |
259 name - The name of the MultiTest. Each Test's name should be prefixed with | 269 name - The name of the MultiTest. Each Test's name should be prefixed with |
260 this name, though this is not enforced. | 270 this name, though this is not enforced. |
261 make_ctx_call - A FuncCall which will be called once before any test in this | 271 make_ctx_call - A FuncCall which will be called once before any test in this |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 print 'UNHANDLED:', obj | 435 print 'UNHANDLED:', obj |
426 return Failure() | 436 return Failure() |
427 | 437 |
428 def finalize(self, aborted): | 438 def finalize(self, aborted): |
429 """Called after __call__() has been called for all results. | 439 """Called after __call__() has been called for all results. |
430 | 440 |
431 @param aborted: True if the user aborted the run. | 441 @param aborted: True if the user aborted the run. |
432 @type aborted: bool | 442 @type aborted: bool |
433 """ | 443 """ |
434 pass | 444 pass |
OLD | NEW |