diff --git a/tests/__init__.py b/tests/__init__.py index 7ed07390ea..df14cf3eb8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -10,7 +10,11 @@ from random import random from unittest.case import TestCase +import sys + +from bzt import ToolError from bzt.cli import CLI +from bzt.engine import SelfDiagnosable from bzt.modules.aggregator import DataPoint, KPISet from bzt.six import u from bzt.utils import run_once, EXE_SUFFIX @@ -105,6 +109,16 @@ def sniff_log(self, log): self.captured_logger.addHandler(self.log_recorder) def tearDown(self): + exc, _, _ = sys.exc_info() + if exc: + try: + if hasattr(self, 'obj') and isinstance(self.obj, SelfDiagnosable): + diags = self.obj.get_error_diagnostics() + if diags: + for line in diags: + logging.info(line) + except BaseException: + pass if self.captured_logger: self.captured_logger.removeHandler(self.log_recorder) self.log_recorder.close() diff --git a/tests/modules/selenium/__init__.py b/tests/modules/selenium/__init__.py index 9839b49194..69ea175596 100644 --- a/tests/modules/selenium/__init__.py +++ b/tests/modules/selenium/__init__.py @@ -37,22 +37,7 @@ def configure(self, config): self.obj.execution = self.obj.execution[0] def tearDown(self): - exc, _, _ = sys.exc_info() - if exc: - try: - stdout_path = os.path.join(self.obj.engine.artifacts_dir, "selenium.out") - if os.path.exists(stdout_path): - stdout = open(stdout_path).read() - logging.info('Selenium stdout: """\n%s\n"""', stdout) - except BaseException: - pass - try: - stdout_path = os.path.join(self.obj.engine.artifacts_dir, "selenium.err") - if os.path.exists(stdout_path): - stderr = open(stdout_path).read() - logging.info('Selenium stderr: """\n%s\n"""', stderr) - except BaseException: - pass + super(SeleniumTestCase, self).tearDown() if isinstance(self.obj, SeleniumExecutor): if isinstance(self.obj.virtual_display_service, VirtualDisplay): self.obj.virtual_display_service.free_virtual_display()