From 4e99f7747ee802ca0b884046904618ce48e0945f Mon Sep 17 00:00:00 2001 From: Jussi Vatjus-Anttila Date: Wed, 10 Jun 2020 16:07:06 +0300 Subject: [PATCH] fix xfail handling --- example/example.py | 5 +++++ pytest_opentmi/OpenTmiReport.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/example/example.py b/example/example.py index 8463c02..d52ce9c 100644 --- a/example/example.py +++ b/example/example.py @@ -37,3 +37,8 @@ def test_skip_marker(): def test_skip(): pytest.skip("unsupported configuration") + + +@pytest.mark.xfail(reason='expected to fail') +def test_xfail(): + raise AssertionError('oh no') diff --git a/pytest_opentmi/OpenTmiReport.py b/pytest_opentmi/OpenTmiReport.py index 06111f4..7206f1f 100644 --- a/pytest_opentmi/OpenTmiReport.py +++ b/pytest_opentmi/OpenTmiReport.py @@ -75,11 +75,11 @@ def _append_failed(self, report): def _append_skipped(self, report): result = self._new_result(report) result.execution.verdict = 'skip' - result.execution.note = report.longrepr[2] if hasattr(report, "wasxfail"): self.xfailed += 1 - result.execution.note = 'xskil' + result.execution.note = f'wasxfail: {report.longrepr.reprcrash.message}' else: + result.execution.note = report.longrepr[2] self.skipped += 1 self.results.append(result) @@ -133,7 +133,10 @@ def _parse_test(self, report): break if report.skipped: test.execution.skip.value = True - test.execution.skip.reason = report.longrepr[2] + if hasattr(report, 'wasxfail'): + test.execution.skip.reason = report.wasxfail + else: + test.execution.skip.reason = report.longrepr[2] return test # pylint: disable=too-many-statements