File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 22import platform
33import sys
44
5+ import pytest
6+
57LINUX = sys .platform .startswith ("linux" )
68MACOS = sys .platform .startswith ("darwin" )
79WIN = sys .platform .startswith ("win32" ) or sys .platform .startswith ("cygwin" )
1214PY2 = sys .version_info .major == 2
1315
1416PY = sys .version_info
17+
18+
19+ def deprecated_call ():
20+ """
21+ pytest.deprecated_call() seems broken in pytest<3.9.x; concretely, it
22+ doesn't work on CPython 3.8.0 with pytest==3.3.2 on Ubuntu 18.04 (#2922).
23+
24+ This is a narrowed reimplementation of the following PR :(
25+ https://github.com/pytest-dev/pytest/pull/4104
26+ """
27+ # TODO: Remove this when testing requires pytest>=3.9.
28+ pieces = pytest .__version__ .split ("." )
29+ pytest_major_minor = (int (pieces [0 ]), int (pieces [1 ]))
30+ if pytest_major_minor < (3 , 9 ):
31+ return pytest .warns ((DeprecationWarning , PendingDeprecationWarning ))
32+ else :
33+ return pytest .deprecated_call ()
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ def cant_convert(v):
301301 cant_convert (3.14159 )
302302 # TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
303303 if (3 , 8 ) <= env .PY < (3 , 10 ):
304- with pytest .deprecated_call ():
304+ with env .deprecated_call ():
305305 assert convert (Int ()) == 42
306306 else :
307307 assert convert (Int ()) == 42
@@ -336,7 +336,7 @@ def require_implicit(v):
336336 # The implicit conversion from np.float32 is undesirable but currently accepted.
337337 # TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
338338 if (3 , 8 ) <= env .PY < (3 , 10 ):
339- with pytest .deprecated_call ():
339+ with env .deprecated_call ():
340340 assert convert (np .float32 (3.14159 )) == 3
341341 else :
342342 assert convert (np .float32 (3.14159 )) == 3
You can’t perform that action at this time.
0 commit comments