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

Side by Side Diff: presubmit_canned_checks.py

Issue 118415: Fixes RunPythonUnitTests output. (Closed)
Patch Set: merge to trunk Created 11 years, 6 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 | « no previous file | tests/presubmit_unittest.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Generic presubmit checks that can be reused by other presubmit checks.""" 6 """Generic presubmit checks that can be reused by other presubmit checks."""
7 7
8 8
9 ### Description checks 9 ### Description checks
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 message_type = output_api.PresubmitNotifyResult 162 message_type = output_api.PresubmitNotifyResult
163 tests_suite = [] 163 tests_suite = []
164 outputs = [] 164 outputs = []
165 for unit_test in unit_tests: 165 for unit_test in unit_tests:
166 try: 166 try:
167 tests_suite.extend(_RunPythonUnitTests_LoadTests(input_api, unit_test)) 167 tests_suite.extend(_RunPythonUnitTests_LoadTests(input_api, unit_test))
168 except ImportError: 168 except ImportError:
169 outputs.append(message_type("Failed to load %s" % unit_test, 169 outputs.append(message_type("Failed to load %s" % unit_test,
170 long_text=input_api.traceback.format_exc())) 170 long_text=input_api.traceback.format_exc()))
171 171
172 results = input_api.unittest.TextTestRunner(verbosity=0).run( 172 buffer = input_api.cStringIO.StringIO()
173 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run(
173 input_api.unittest.TestSuite(tests_suite)) 174 input_api.unittest.TestSuite(tests_suite))
174 if not results.wasSuccessful(): 175 if not results.wasSuccessful():
175 outputs.append(message_type("%d unit tests failed." % 176 outputs.append(message_type("%d unit tests failed." %
176 (len(results.failures) + len(results.errors)))) 177 (len(results.failures) + len(results.errors)),
178 long_text=buffer.getvalue()))
177 return outputs 179 return outputs
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698