summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-06-09 13:13:52 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-06-09 13:20:22 -0700
commitf725d80ad8fbbbc85698052ca62fd58b581f5e7f (patch)
tree081929e0fea0a54e839825a100ab0a62a416e581 /numpy
parent368baf45d023084798231e5abd0135783a2fc7c6 (diff)
downloadnumpy-f725d80ad8fbbbc85698052ca62fd58b581f5e7f.tar.gz
TST: Fixup loadtxt int-via-float tests when in release mode
In release mode, the DeprecationWarning is not automatically raised, so we need to ensure this using a warning filter. (Also add missing metadata/info to the deprecation tests) Closes gh-21706
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_deprecations.py6
-rw-r--r--numpy/lib/tests/test_loadtxt.py2
2 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index a10dacd49..2b7864433 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -1216,6 +1216,12 @@ class TestAxisNotMAXDIMS(_DeprecationTestCase):
class TestLoadtxtParseIntsViaFloat(_DeprecationTestCase):
+ # Deprecated 2022-07-03, NumPy 1.23
+ # This test can be removed without replacement after the deprecation.
+ # The tests:
+ # * numpy/lib/tests/test_loadtxt.py::test_integer_signs
+ # * lib/tests/test_loadtxt.py::test_implicit_cast_float_to_int_fails
+ # Have a warning filter that needs to be removed.
message = r"loadtxt\(\): Parsing an integer via a float is deprecated.*"
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])
diff --git a/numpy/lib/tests/test_loadtxt.py b/numpy/lib/tests/test_loadtxt.py
index f50e3b8ad..8839ef0a8 100644
--- a/numpy/lib/tests/test_loadtxt.py
+++ b/numpy/lib/tests/test_loadtxt.py
@@ -390,6 +390,7 @@ def test_bool():
@pytest.mark.skipif(IS_PYPY and sys.implementation.version <= (7, 3, 8),
reason="PyPy bug in error formatting")
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])
+@pytest.mark.filterwarnings("error:.*integer via a float.*:DeprecationWarning")
def test_integer_signs(dtype):
dtype = np.dtype(dtype)
assert np.loadtxt(["+2"], dtype=dtype) == 2
@@ -407,6 +408,7 @@ def test_integer_signs(dtype):
@pytest.mark.skipif(IS_PYPY and sys.implementation.version <= (7, 3, 8),
reason="PyPy bug in error formatting")
@pytest.mark.parametrize("dtype", np.typecodes["AllInteger"])
+@pytest.mark.filterwarnings("error:.*integer via a float.*:DeprecationWarning")
def test_implicit_cast_float_to_int_fails(dtype):
txt = StringIO("1.0, 2.1, 3.7\n4, 5, 6")
with pytest.raises(ValueError):