Skip to content

Commit 95bd232

Browse files
Apply suggestions from @bluetech
1 parent 5ebcb34 commit 95bd232

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/_pytest/nodes.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from _pytest.mark.structures import MarkDecorator
3030
from _pytest.mark.structures import NodeKeywords
3131
from _pytest.outcomes import fail
32-
from _pytest.outcomes import Failed
3332
from _pytest.store import Store
3433

3534
if TYPE_CHECKING:
@@ -332,19 +331,15 @@ def _prunetraceback(self, excinfo):
332331
pass
333332

334333
def _repr_failure_py(
335-
self,
336-
excinfo: ExceptionInfo[
337-
Union[Failed, FixtureLookupError, ConftestImportFailure]
338-
],
339-
style=None,
334+
self, excinfo: ExceptionInfo[BaseException], style=None,
340335
) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]:
336+
if isinstance(excinfo.value, ConftestImportFailure):
337+
excinfo = ExceptionInfo(excinfo.value.excinfo)
341338
if isinstance(excinfo.value, fail.Exception):
342339
if not excinfo.value.pytrace:
343340
return str(excinfo.value)
344341
if isinstance(excinfo.value, FixtureLookupError):
345342
return excinfo.value.formatrepr()
346-
if isinstance(excinfo.value, ConftestImportFailure):
347-
excinfo = ExceptionInfo(excinfo.value.excinfo) # type: ignore
348343
if self.config.getoption("fulltrace", False):
349344
style = "long"
350345
else:

testing/test_reports.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ def test_report_prevent_ConftestImportFailure_hiding_exception(self, testdir):
404404
result.stdout.fnmatch_lines(
405405
["E ModuleNotFoundError: No module named 'unknown'"]
406406
)
407-
result.stdout.no_fnmatch_line(
408-
"ERROR - _pytest.config.ConftestImportFailure: ModuleNotFoundError:*"
409-
)
407+
result.stdout.no_fnmatch_line("ERROR - *ConftestImportFailure*")
410408

411409

412410
class TestHooks:

0 commit comments

Comments
 (0)