mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Make sure all warnings in pytest get turned into errors (#2838)
* Make sure all warnings in pytest get turned into errors * Suppress DeprecationWarnings in test_int_convert and test_numpy_int_convert * PyLong_AsLong only shouts "Deprecated!" on Python>=3.8 * Fix remaining warnings on PyPy and CPython 3.10-dev
This commit is contained in:
@@ -299,7 +299,12 @@ def test_int_convert():
|
||||
assert convert(7) == 7
|
||||
assert noconvert(7) == 7
|
||||
cant_convert(3.14159)
|
||||
assert convert(Int()) == 42
|
||||
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
|
||||
if (3, 8) <= env.PY < (3, 10):
|
||||
with pytest.deprecated_call():
|
||||
assert convert(Int()) == 42
|
||||
else:
|
||||
assert convert(Int()) == 42
|
||||
requires_conversion(Int())
|
||||
cant_convert(NotInt())
|
||||
cant_convert(Float())
|
||||
@@ -329,7 +334,12 @@ def test_numpy_int_convert():
|
||||
assert noconvert(np.intc(42)) == 42
|
||||
|
||||
# The implicit conversion from np.float32 is undesirable but currently accepted.
|
||||
assert convert(np.float32(3.14159)) == 3
|
||||
# TODO: Avoid DeprecationWarning in `PyLong_AsLong` (and similar)
|
||||
if (3, 8) <= env.PY < (3, 10):
|
||||
with pytest.deprecated_call():
|
||||
assert convert(np.float32(3.14159)) == 3
|
||||
else:
|
||||
assert convert(np.float32(3.14159)) == 3
|
||||
require_implicit(np.float32(3.14159))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user