Skip to content

Commit b30e72c

Browse files
rwgkInvincibleRMCgentlegiantJGC
authored
Replace env.deprecated_call() with pytest.deprecated_call() (#5893)
Since we already require pytest>=6 (see tests/requirements.txt), the old compatibility function is obsolete and pytest.deprecated_call() can be used directly. Extracted from PR #5879 Co-authored-by: Michael Carlstrom <[email protected]> Co-authored-by: gentlegiantJGC <[email protected]>
1 parent 3370fe1 commit b30e72c

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

tests/env.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import sys
55
import sysconfig
66

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

tests/test_builtin_casters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def cant_convert(v):
304304
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
305305
# TODO: PyPy 3.8 does not behave like CPython 3.8 here yet (7.3.7)
306306
if sys.version_info < (3, 10) and env.CPYTHON:
307-
with env.deprecated_call():
307+
with pytest.deprecated_call():
308308
assert convert(Int()) == 42
309309
else:
310310
assert convert(Int()) == 42
@@ -377,7 +377,7 @@ def require_implicit(v):
377377
# TODO: PyPy 3.8 does not behave like CPython 3.8 here yet (7.3.7)
378378
# https://github.com/pybind/pybind11/issues/3408
379379
if (3, 8) <= sys.version_info < (3, 10) and env.CPYTHON:
380-
with env.deprecated_call():
380+
with pytest.deprecated_call():
381381
assert convert(np.float32(3.14159)) == 3
382382
else:
383383
assert convert(np.float32(3.14159)) == 3

0 commit comments

Comments
 (0)