summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-07 13:03:04 +0200
committerCharles Harris <charlesr.harris@gmail.com>2022-06-03 09:13:48 -0600
commitdc66f5b2bcbedc412cbe567efee412eaf2a93ede (patch)
treec4e0e1322939d8914c259fa5c4e326e7d1f7f116 /numpy/core
parenta10a73ebfe3c3fab0dbd6cecfb6a8f81b380aa23 (diff)
downloadnumpy-dc66f5b2bcbedc412cbe567efee412eaf2a93ede.tar.gz
BUG: Fix TestConversion.test_to_int_scalar() on Python.
The delegation of int() to __trunc__ was deprecated in Python 3.11, see https://github.com/python/cpython/commit/b4bd1e1422997de61faf506b4916e83013bc7d21
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/test_multiarray.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 1b29c1f8b..f4454130d 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -8583,11 +8583,16 @@ class TestConversion:
assert_equal(5, int_func(np.bytes_(b'5')))
assert_equal(6, int_func(np.unicode_(u'6')))
- class HasTrunc:
- def __trunc__(self):
- return 3
- assert_equal(3, int_func(np.array(HasTrunc())))
- assert_equal(3, int_func(np.array([HasTrunc()])))
+ # The delegation of int() to __trunc__ was deprecated in
+ # Python 3.11.
+ if sys.version_info < (3, 11):
+ class HasTrunc:
+ def __trunc__(self):
+ return 3
+ assert_equal(3, int_func(np.array(HasTrunc())))
+ assert_equal(3, int_func(np.array([HasTrunc()])))
+ else:
+ pass
class NotConvertible:
def __int__(self):