Create a `test` local variable to greatly shorten RegressionManager.handle_result
@@ -241,8 +241,10 @@ class RegressionManager(object):
Args:
result: The sub-exception of TestComplete to raise.
"""
- real_time = time.time() - self._running_test.start_time
- sim_time_ns = get_sim_time('ns') - self._running_test.start_sim_time
+ test = self._running_test
+
+ real_time = time.time() - test.start_time
+ sim_time_ns = get_sim_time('ns') - test.start_sim_time
try:
ratio_time = sim_time_ns / real_time
except ZeroDivisionError:
@@ -250,33 +252,31 @@ class RegressionManager(object):
ratio_time = float('nan')
else:
ratio_time = float('inf')
- self.xunit.add_testcase(name=self._running_test.funcname,
- classname=self._running_test.module,
+ self.xunit.add_testcase(name=test.funcname,
+ classname=test.module,
time=repr(real_time),
sim_time_ns=repr(sim_time_ns),
ratio_time=repr(ratio_time))
- running_test_funcname = self._running_test.funcname
-
# Helper for logging result
def _result_was():
result_was = ("%s (result was %s)" %
- (running_test_funcname, result.__class__.__name__))
+ (test.funcname, result.__class__.__name__))
return result_was
result_pass = True
if (isinstance(result, TestSuccess) and
- not self._running_test.expect_fail and
- not self._running_test.expect_error):
- self.log.info("Test Passed: %s" % running_test_funcname)
+ not test.expect_fail and
+ not test.expect_error):
+ self.log.info("Test Passed: %s" % test.funcname)
elif (isinstance(result, TestFailure) and
- self._running_test.expect_fail):
+ test.expect_fail):
self.log.info("Test failed as expected: " + _result_was())
elif (isinstance(result, TestSuccess) and
- self._running_test.expect_error):
+ test.expect_error):
self.log.error("Test passed but we expected an error: " +
_result_was())
self._add_failure(result)
@@ -288,17 +288,17 @@ class RegressionManager(object):
self._add_failure(result)
result_pass = False
- elif isinstance(result, TestError) and self._running_test.expect_error:
+ elif isinstance(result, TestError) and test.expect_error:
self.log.info("Test errored as expected: " + _result_was())
elif isinstance(result, SimFailure):
- if self._running_test.expect_error:
+ if test.expect_error:
self.log.info("Test errored as expected: " + _result_was())
else:
self.log.error("Test error has lead to simulator shutting us "
"down")
self._add_failure(result)
- self._store_test_result(self._running_test.module, self._running_test.funcname, False, sim_time_ns, real_time, ratio_time)
+ self._store_test_result(test.module, test.funcname, False, sim_time_ns, real_time, ratio_time)
self.tear_down()
return
@@ -307,7 +307,7 @@ class RegressionManager(object):
self._add_failure(result)
result_pass = False
- self._store_test_result(self._running_test.module, self._running_test.funcname, result_pass, sim_time_ns, real_time, ratio_time)
+ self._store_test_result(test.module, test.funcname, result_pass, sim_time_ns, real_time, ratio_time)
self.execute()
