Apply suggestions from @bluetech

This commit is contained in:
Florian Dahlitz 2020-05-26 10:31:53 +02:00
parent 5ebcb34fb5
commit 95bd232e57
No known key found for this signature in database
GPG Key ID: 628E551560123F45
2 changed files with 4 additions and 11 deletions

View File

@ -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:

View File

@ -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: