From 95bd232e57603329e16bb3a4c694e4fe78655c7b Mon Sep 17 00:00:00 2001 From: Florian Dahlitz Date: Tue, 26 May 2020 10:31:53 +0200 Subject: [PATCH] Apply suggestions from @bluetech --- src/_pytest/nodes.py | 11 +++-------- testing/test_reports.py | 4 +--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 5aae211cd..2ed250610 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -29,7 +29,6 @@ from _pytest.mark.structures import Mark from _pytest.mark.structures import MarkDecorator from _pytest.mark.structures import NodeKeywords from _pytest.outcomes import fail -from _pytest.outcomes import Failed from _pytest.store import Store if TYPE_CHECKING: @@ -332,19 +331,15 @@ class Node(metaclass=NodeMeta): pass def _repr_failure_py( - self, - excinfo: ExceptionInfo[ - Union[Failed, FixtureLookupError, ConftestImportFailure] - ], - style=None, + self, excinfo: ExceptionInfo[BaseException], style=None, ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: + if isinstance(excinfo.value, ConftestImportFailure): + excinfo = ExceptionInfo(excinfo.value.excinfo) if isinstance(excinfo.value, fail.Exception): if not excinfo.value.pytrace: return str(excinfo.value) if isinstance(excinfo.value, FixtureLookupError): return excinfo.value.formatrepr() - if isinstance(excinfo.value, ConftestImportFailure): - excinfo = ExceptionInfo(excinfo.value.excinfo) # type: ignore if self.config.getoption("fulltrace", False): style = "long" else: diff --git a/testing/test_reports.py b/testing/test_reports.py index 64d86e953..9e4e7d09d 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -404,9 +404,7 @@ class TestReportSerialization: result.stdout.fnmatch_lines( ["E ModuleNotFoundError: No module named 'unknown'"] ) - result.stdout.no_fnmatch_line( - "ERROR - _pytest.config.ConftestImportFailure: ModuleNotFoundError:*" - ) + result.stdout.no_fnmatch_line("ERROR - *ConftestImportFailure*") class TestHooks: