From c1486ca4c3b27dca270838399e59f0b8ab527ba1 Mon Sep 17 00:00:00 2001 From: Jussi Vatjus-Anttila Date: Mon, 30 Aug 2021 10:00:15 +0300 Subject: [PATCH] check before getting message (#11) * check before getting message * pylint: use-dict-literal --- pytest_opentmi/OpenTmiReport.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pytest_opentmi/OpenTmiReport.py b/pytest_opentmi/OpenTmiReport.py index 94311e9..72b5741 100644 --- a/pytest_opentmi/OpenTmiReport.py +++ b/pytest_opentmi/OpenTmiReport.py @@ -27,7 +27,7 @@ def __init__(self, config): self.test_logs = [] self.results = [] self.tests = [] - self._items = dict() + self._items = {} self.errors = self.failed = 0 self.passed = self.skipped = 0 self.xfailed = self.xpassed = 0 @@ -87,8 +87,11 @@ def _append_inconclusive(self, report): # For now, the only "other" the plugin give support is rerun result = self._new_result(report) result.execution.verdict = 'inconclusive' - result.execution.note = f'{report.longrepr.reprcrash.message}\n' \ - f'{report.longrepr.reprcrash.path}:{report.longrepr.reprcrash.lineno}' + if report.longrepr.reprcrash: + result.execution.note = f'{report.longrepr.reprcrash.message}\n' \ + f'{report.longrepr.reprcrash.path}:{report.longrepr.reprcrash.lineno}' + else: + result.execution.note = '' self.results.append(result) # pylint: disable=too-many-branches @@ -154,7 +157,7 @@ def _new_result(self, report): result.job.id = os.environ.get('BUILD_TAG', str(uuid.uuid1())) result.campaign = os.environ.get('JOB_NAME', "") if report.user_properties: - result.execution.profiling['properties'] = dict() + result.execution.profiling['properties'] = {} for (key, value) in report.user_properties: result.execution.profiling['properties'][key] = value if report.keywords: