Skip to content

Commit 0a020fa

Browse files
authored
Bump pytest to >=7.4.0 (#15611)
The 7.4.0 release of pytest broke mypy because we were using some undocumented, private API that was removed. Ideally we'd stop using the private API, but nobody seems to remember why we started using the private API in the first place (see #15501 (comment), and following comments). For now it (unfortunately) seems safer to just migrate to the new private API rather than try to figure out an alternative using public API. I also took @bluetech's advice in #15501 (comment) to improve the type annotations in the method in question.
1 parent 67cc059 commit 0a020fa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mypy/test/data.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ def teardown(self) -> None:
378378
def reportinfo(self) -> tuple[str, int, str]:
379379
return self.file, self.line, self.name
380380

381-
def repr_failure(self, excinfo: Any, style: Any | None = None) -> str:
381+
def repr_failure(
382+
self, excinfo: pytest.ExceptionInfo[BaseException], style: Any | None = None
383+
) -> str:
384+
excrepr: object
382385
if isinstance(excinfo.value, SystemExit):
383386
# We assume that before doing exit() (which raises SystemExit) we've printed
384387
# enough context about what happened so that a stack trace is not useful.
@@ -388,7 +391,7 @@ def repr_failure(self, excinfo: Any, style: Any | None = None) -> str:
388391
elif isinstance(excinfo.value, pytest.fail.Exception) and not excinfo.value.pytrace:
389392
excrepr = excinfo.exconly()
390393
else:
391-
self.parent._prunetraceback(excinfo)
394+
excinfo.traceback = self.parent._traceback_filter(excinfo)
392395
excrepr = excinfo.getrepr(style="short")
393396

394397
return f"data: {self.file}:{self.line}:\n{excrepr}"

test-requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ lxml>=4.9.1,<4.9.3; (python_version<'3.11' or sys_platform!='win32') and python_
88
pre-commit
99
pre-commit-hooks==4.4.0
1010
psutil>=4.0
11-
# pytest 6.2.3 does not support Python 3.10
12-
# TODO: fix use of removed private APIs so we can use the latest pytest
13-
pytest>=6.2.4,<7.4.0
11+
pytest>=7.4.0
1412
pytest-xdist>=1.34.0
1513
pytest-cov>=2.10.0
1614
ruff==0.0.272 # must match version in .pre-commit-config.yaml

0 commit comments

Comments
 (0)