Merge "Fixed order and cleaned up unused vars"
diff --git a/acts/framework/acts/asserts.py b/acts/framework/acts/asserts.py
index 15cc752..029906e 100644
--- a/acts/framework/acts/asserts.py
+++ b/acts/framework/acts/asserts.py
@@ -44,6 +44,7 @@
extras: An optional field for extra information to be included in
test result.
"""
+ my_msg = None
try:
_pyunit_proxy.assertEqual(first, second)
except Exception as e:
@@ -55,6 +56,8 @@
my_msg = str(e)
if msg:
my_msg = "%s %s" % (my_msg, msg)
+ # This is a hack to remove the stacktrace produced by the above exception.
+ if my_msg is not None:
fail(my_msg, extras=extras)
@@ -75,6 +78,7 @@
:param extras: Extra object passed to test failure handler
:return:
"""
+ my_msg = None
try:
if delta:
_pyunit_proxy.assertAlmostEqual(
@@ -86,6 +90,8 @@
my_msg = str(e)
if msg:
my_msg = "%s %s" % (my_msg, msg)
+ # This is a hack to remove the stacktrace produced by the above exception.
+ if my_msg is not None:
fail(my_msg, extras=extras)
diff --git a/acts/framework/acts/base_test.py b/acts/framework/acts/base_test.py
index 873c7eb..8c28137 100755
--- a/acts/framework/acts/base_test.py
+++ b/acts/framework/acts/base_test.py
@@ -16,14 +16,15 @@
import logging
import os
import traceback
+from concurrent.futures import ThreadPoolExecutor
from acts import asserts
+from acts import keys
from acts import logger
from acts import records
from acts import signals
from acts import tracelogger
from acts import utils
-from concurrent.futures import ThreadPoolExecutor
# Macro strings for test result reporting
TEST_CASE_TOKEN = "[Test Case]"
@@ -400,7 +401,11 @@
tr_record.add_error("teardown_test", e)
self._exec_procedure_func(self._on_exception, tr_record)
except (signals.TestFailure, AssertionError) as e:
- self.log.error(e)
+ if self.user_params.get(
+ keys.Config.key_test_failure_tracebacks.value, False):
+ self.log.exception(e)
+ else:
+ self.log.error(e)
tr_record.test_fail(e)
self._exec_procedure_func(self._on_fail, tr_record)
except signals.TestSkip as e:
@@ -500,10 +505,10 @@
if format_args:
self.exec_one_testcase(test_name, test_func,
- args + (setting, ), **kwargs)
+ args + (setting,), **kwargs)
else:
self.exec_one_testcase(test_name, test_func,
- (setting, ) + args, **kwargs)
+ (setting,) + args, **kwargs)
if len(self.results.passed) - previous_success_cnt != 1:
failed_settings.append(setting)
diff --git a/acts/framework/acts/config_parser.py b/acts/framework/acts/config_parser.py
index 4a9625f..fece155 100755
--- a/acts/framework/acts/config_parser.py
+++ b/acts/framework/acts/config_parser.py
@@ -25,7 +25,8 @@
# An environment variable defining the base location for ACTS logs.
_ENV_ACTS_LOGPATH = 'ACTS_LOGPATH'
-
+# An environment variable that enables test case failures to log stack traces.
+_ENV_TEST_FAILURE_TRACEBACKS = 'ACTS_TEST_FAILURE_TRACEBACKS'
# An environment variable defining the test search paths for ACTS.
_ENV_ACTS_TESTPATHS = 'ACTS_TESTPATHS'
_PATH_SEPARATOR = ':'
@@ -284,6 +285,10 @@
(os.environ[_ENV_ACTS_TESTPATHS]))
configs[keys.Config.key_test_paths.value] = os.environ[
_ENV_ACTS_TESTPATHS].split(_PATH_SEPARATOR)
+ if (keys.Config.key_test_failure_tracebacks not in configs
+ and _ENV_TEST_FAILURE_TRACEBACKS in os.environ):
+ configs[keys.Config.key_test_failure_tracebacks.value] = os.environ[
+ _ENV_TEST_FAILURE_TRACEBACKS]
# Add the global paths to the global config.
k_log_path = keys.Config.key_log_path.value
diff --git a/acts/framework/acts/keys.py b/acts/framework/acts/keys.py
index d1f6bf7..36a19ac 100644
--- a/acts/framework/acts/keys.py
+++ b/acts/framework/acts/keys.py
@@ -35,6 +35,7 @@
key_address = "Address"
key_random = "random"
key_test_case_iterations = "test_case_iterations"
+ key_test_failure_tracebacks = "test_failure_tracebacks"
# Config names for controllers packaged in ACTS.
key_android_device = "AndroidDevice"
key_chameleon_device = "ChameleonDevice"