From dadfa82c768027fe2dd19ebcf08bb845d7ca3ae8 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Wed, 1 May 2019 16:24:05 -0700 Subject: MAINT: more adjustments in PR 10723 * adjust test_longdouble_from_int to properly handle platforms where np.longdouble and np.double have roughly equivalent limits --- numpy/core/tests/test_longdouble.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py index 66293e988..ee4197f8f 100644 --- a/numpy/core/tests/test_longdouble.py +++ b/numpy/core/tests/test_longdouble.py @@ -1,5 +1,6 @@ from __future__ import division, absolute_import, print_function +import warnings import pytest import numpy as np @@ -213,7 +214,18 @@ class TestCommaDecimalPointLocale(CommaDecimalPointLocale): def test_longdouble_from_int(int_val): # for issue gh-9968 str_val = str(int_val) - assert np.longdouble(int_val) == np.longdouble(str_val) + # we'll expect a RuntimeWarning on platforms + # with np.longdouble equivalent to np.double + # for large integer input + with warnings.catch_warnings(record=True) as w: + warnings.filterwarnings('always', '', RuntimeWarning) + # can be inf==inf on some platforms + assert np.longdouble(int_val) == np.longdouble(str_val) + # we can't directly compare the int and + # max longdouble value on all platforms + if np.allclose(np.finfo(np.longdouble).max, + np.finfo(np.double).max) and w: + assert w[0].category is RuntimeWarning @pytest.mark.parametrize("bool_val", [ True, False]) -- cgit v1.2.1