Move ConftestImportFailure check to correct position and add typing

This commit is contained in:
Florian Dahlitz 2020-05-25 20:19:28 +02:00
parent 6546d1f725
commit 5ebcb34fb5
No known key found for this signature in database
GPG Key ID: 628E551560123F45
1 changed files with 7 additions and 3 deletions

View File

@ -332,17 +332,21 @@ class Node(metaclass=NodeMeta):
pass
def _repr_failure_py(
self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]], style=None
self,
excinfo: ExceptionInfo[
Union[Failed, FixtureLookupError, ConftestImportFailure]
],
style=None,
) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]:
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"
if excinfo.type is ConftestImportFailure: # type: ignore
excinfo = ExceptionInfo.from_exc_info(excinfo.value.excinfo) # type: ignore
else:
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
self._prunetraceback(excinfo)