OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Helper module for calling python-based tests.""" | 5 """Helper module for calling python-based tests.""" |
6 | 6 |
7 | 7 |
8 import logging | 8 import logging |
9 import sys | 9 import sys |
10 import time | 10 import time |
11 | 11 |
12 from test_result import TestResults | 12 from pylib.test_result import TestResults |
13 | 13 |
14 | 14 |
15 def CallPythonTest(test, options): | 15 def CallPythonTest(test, options): |
16 """Invokes a test function and translates Python exceptions into test results. | 16 """Invokes a test function and translates Python exceptions into test results. |
17 | 17 |
18 This method invokes SetUp()/TearDown() on the test. It is intended to be | 18 This method invokes SetUp()/TearDown() on the test. It is intended to be |
19 resilient to exceptions in SetUp(), the test itself, and TearDown(). Any | 19 resilient to exceptions in SetUp(), the test itself, and TearDown(). Any |
20 Python exception means the test is marked as failed, and the test result will | 20 Python exception means the test is marked as failed, and the test result will |
21 contain information about the exception. | 21 contain information about the exception. |
22 | 22 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 test.qualified_name) | 75 test.qualified_name) |
76 if not failed: | 76 if not failed: |
77 # Don't stomp the error during the test if TearDown blows up. This is a | 77 # Don't stomp the error during the test if TearDown blows up. This is a |
78 # trade-off: if the test fails, this will mask any problem with TearDown | 78 # trade-off: if the test fails, this will mask any problem with TearDown |
79 # until the test is fixed. | 79 # until the test is fixed. |
80 exc_info = sys.exc_info() | 80 exc_info = sys.exc_info() |
81 result = TestResults.FromPythonException(test.qualified_name, | 81 result = TestResults.FromPythonException(test.qualified_name, |
82 start_date_ms, exc_info) | 82 start_date_ms, exc_info) |
83 | 83 |
84 return result | 84 return result |
OLD | NEW |