Skip to content

Commit 962c9fa

Browse files
committed
Add back env.deprecated_call
Signed-off-by: Michael Carlstrom <[email protected]>
1 parent a956052 commit 962c9fa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def check(
332332
expected: _EXPECTED_T,
333333
) -> bool:
334334
if sys.version_info < (3, 10) and env.CPYTHON:
335-
with pytest.deprecated_call():
335+
with env.deprecated_call():
336336
return convert(value) == expected
337337
else:
338338
return convert(value) == expected

tests/env.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import platform
44
import sys
55
import sysconfig
6+
from typing import Any
7+
8+
import pytest
69

710
ANDROID = sys.platform.startswith("android")
811
LINUX = sys.platform.startswith("linux")
@@ -27,3 +30,19 @@
2730
or GRAALPY
2831
or (CPYTHON and PY_GIL_DISABLED and (3, 13) <= sys.version_info < (3, 14))
2932
)
33+
34+
35+
def deprecated_call() -> Any:
36+
"""
37+
pytest.deprecated_call() seems broken in pytest<3.9.x; concretely, it
38+
doesn't work on CPython 3.8.0 with pytest==3.3.2 on Ubuntu 18.04 (#2922).
39+
40+
This is a narrowed reimplementation of the following PR :(
41+
https://github.com/pytest-dev/pytest/pull/4104
42+
"""
43+
# TODO: Remove this when testing requires pytest>=3.9.
44+
pieces = pytest.__version__.split(".")
45+
pytest_major_minor = (int(pieces[0]), int(pieces[1]))
46+
if pytest_major_minor < (3, 9):
47+
return pytest.warns((DeprecationWarning, PendingDeprecationWarning))
48+
return pytest.deprecated_call()

0 commit comments

Comments
 (0)