summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_arrayprint.py13
-rw-r--r--numpy/core/tests/test_datetime.py5
-rw-r--r--numpy/core/tests/test_deprecations.py6
-rw-r--r--numpy/core/tests/test_dtype.py6
-rw-r--r--numpy/core/tests/test_errstate.py5
-rw-r--r--numpy/core/tests/test_extint128.py5
-rw-r--r--numpy/core/tests/test_half.py6
-rw-r--r--numpy/core/tests/test_indexing.py5
-rw-r--r--numpy/core/tests/test_longdouble.py40
-rw-r--r--numpy/core/tests/test_mem_overlap.py18
-rw-r--r--numpy/core/tests/test_memmap.py10
-rw-r--r--numpy/core/tests/test_multiarray.py15
-rw-r--r--numpy/core/tests/test_nditer.py7
-rw-r--r--numpy/core/tests/test_numeric.py9
-rw-r--r--numpy/core/tests/test_print.py7
-rw-r--r--numpy/core/tests/test_regression.py17
-rw-r--r--numpy/core/tests/test_scalar_ctors.py20
-rw-r--r--numpy/core/tests/test_scalarbuffer.py12
-rw-r--r--numpy/core/tests/test_scalarmath.py12
-rw-r--r--numpy/core/tests/test_umath.py22
-rw-r--r--numpy/core/tests/test_umath_complex.py51
21 files changed, 165 insertions, 126 deletions
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 6c2403e67..189eabf9b 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function
-import sys, gc
+import sys
+import gc
+import pytest
import numpy as np
from numpy.testing import (
- run_module_suite, assert_, assert_equal, assert_raises, assert_warns, dec,
-)
+ run_module_suite, assert_, assert_equal, assert_raises, assert_warns,
+ HAS_REFCOUNT,
+ )
import textwrap
class TestArrayRepr(object):
@@ -34,7 +37,7 @@ class TestArrayRepr(object):
" [(1,), (1,)]], dtype=[('a', '<i4')])"
)
- @dec.knownfailureif(True, "See gh-10544")
+ @pytest.mark.xfail(reason="See gh-10544")
def test_object_subclass(self):
class sub(np.ndarray):
def __new__(cls, inp):
@@ -388,7 +391,7 @@ class TestArray2String(object):
"[ 'xxxxx']"
)
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_refcount(self):
# make sure we do not hold references to the array due to a recursive
# closure (gh-10620)
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index ba291737a..f660d8869 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -5,9 +5,10 @@ import pickle
import numpy
import numpy as np
import datetime
+import pytest
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_raises,
- assert_warns, dec, suppress_warnings
+ assert_warns, suppress_warnings
)
# Use pytz to test out various time zones if available
@@ -1487,7 +1488,7 @@ class TestDateTime(object):
np.datetime64('2032-01-01T00:00:00', 'us'), unit='auto'),
'2032-01-01')
- @dec.skipif(not _has_pytz, "The pytz module is not available.")
+ @pytest.mark.skipif(not _has_pytz, reason="The pytz module is not available.")
def test_datetime_as_string_timezone(self):
# timezone='local' vs 'UTC'
a = np.datetime64('2010-03-15T06:30', 'm')
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 2c2900e6c..bbb6697ab 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -9,11 +9,12 @@ import datetime
import sys
import operator
import warnings
+import pytest
import numpy as np
from numpy.testing import (
run_module_suite, assert_raises, assert_warns, assert_no_warnings,
- assert_array_equal, assert_, dec)
+ assert_array_equal, assert_)
try:
import pytz
@@ -242,7 +243,8 @@ class TestDatetime64Timezone(_DeprecationTestCase):
self.assert_deprecated(np.datetime64, args=('2000-01-01T00+01',))
self.assert_deprecated(np.datetime64, args=('2000-01-01T00Z',))
- @dec.skipif(not _has_pytz, "The pytz module is not available.")
+ @pytest.mark.skipif(not _has_pytz,
+ reason="The pytz module is not available.")
def test_datetime(self):
tz = pytz.timezone('US/Eastern')
dt = datetime.datetime(2000, 1, 1, 0, 0, tzinfo=tz)
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index c924e6f43..f8a724832 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -3,12 +3,12 @@ from __future__ import division, absolute_import, print_function
import pickle
import sys
import operator
+import pytest
import numpy as np
from numpy.core._rational_tests import rational
from numpy.testing import (
- run_module_suite, assert_, assert_equal, assert_raises,
- dec
+ run_module_suite, assert_, assert_equal, assert_raises
)
def assert_dtype_equal(a, b):
@@ -593,7 +593,7 @@ class TestString(object):
assert_equal(repr(dt),
"dtype([('a', '<M8[D]'), ('b', '<m8[us]')])")
- @dec.skipif(sys.version_info[0] >= 3)
+ @pytest.mark.skipif(sys.version_info[0] >= 3, reason="Python 2 only")
def test_dtype_str_with_long_in_shape(self):
# Pull request #376, should not error
np.dtype('(1L,)i4')
diff --git a/numpy/core/tests/test_errstate.py b/numpy/core/tests/test_errstate.py
index ae06af7fd..212073362 100644
--- a/numpy/core/tests/test_errstate.py
+++ b/numpy/core/tests/test_errstate.py
@@ -1,13 +1,14 @@
from __future__ import division, absolute_import, print_function
import platform
+import pytest
import numpy as np
-from numpy.testing import assert_, run_module_suite, dec
+from numpy.testing import assert_, run_module_suite
class TestErrstate(object):
- @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
+ @pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
def test_invalid(self):
with np.errstate(all='raise', under='ignore'):
a = -np.arange(3)
diff --git a/numpy/core/tests/test_extint128.py b/numpy/core/tests/test_extint128.py
index 31786124d..b041fb0d5 100644
--- a/numpy/core/tests/test_extint128.py
+++ b/numpy/core/tests/test_extint128.py
@@ -4,12 +4,13 @@ import sys
import itertools
import contextlib
import operator
+import pytest
import numpy as np
import numpy.core._multiarray_tests as mt
from numpy.compat import long
-from numpy.testing import assert_raises, assert_equal, dec
+from numpy.testing import assert_raises, assert_equal
INT64_MAX = np.iinfo(np.int64).max
@@ -183,7 +184,7 @@ def test_gt_128():
assert_equal(d, c)
-@dec.slow
+@pytest.mark.slow
def test_divmod_128_64():
with exc_iter(INT128_VALUES, INT64_POS_VALUES) as it:
for a, b in it:
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
index 813cf9572..080f136a5 100644
--- a/numpy/core/tests/test_half.py
+++ b/numpy/core/tests/test_half.py
@@ -1,10 +1,11 @@
from __future__ import division, absolute_import, print_function
import platform
+import pytest
import numpy as np
from numpy import uint16, float16, float32, float64
-from numpy.testing import run_module_suite, assert_, assert_equal, dec
+from numpy.testing import run_module_suite, assert_, assert_equal
def assert_raises_fpe(strmatch, callable, *args, **kwargs):
@@ -355,7 +356,8 @@ class TestHalf(object):
assert_equal(np.power(b32, a16).dtype, float16)
assert_equal(np.power(b32, b16).dtype, float32)
- @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
+ @pytest.mark.skipif(platform.machine() == "armv5tel",
+ reason="See gh-413.")
def test_half_fpe(self):
with np.errstate(all='raise'):
sx16 = np.array((1e-4,), dtype=float16)
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py
index 082ecb496..01330ac55 100644
--- a/numpy/core/tests/test_indexing.py
+++ b/numpy/core/tests/test_indexing.py
@@ -4,13 +4,14 @@ import sys
import warnings
import functools
import operator
+import pytest
import numpy as np
from numpy.core._multiarray_tests import array_indexing
from itertools import product
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_raises,
- assert_array_equal, assert_warns, dec, HAS_REFCOUNT, suppress_warnings,
+ assert_array_equal, assert_warns, HAS_REFCOUNT, suppress_warnings,
)
@@ -608,7 +609,7 @@ class TestSubclasses(object):
assert_array_equal(new_s.finalize_status, new_s)
assert_array_equal(new_s.old, s)
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_slice_decref_getsetslice(self):
# See gh-10066, a temporary slice object should be discarted.
# This test is only really interesting on Python 2 since
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py
index 7cd5b04d8..302bfe9ec 100644
--- a/numpy/core/tests/test_longdouble.py
+++ b/numpy/core/tests/test_longdouble.py
@@ -1,10 +1,10 @@
from __future__ import division, absolute_import, print_function
-import locale
+import pytest
import numpy as np
from numpy.testing import (
- run_module_suite, assert_, assert_equal, dec, assert_raises,
+ run_module_suite, assert_, assert_equal, assert_raises,
assert_array_equal, temppath,
)
from ._locales import CommaDecimalPointLocale
@@ -30,8 +30,8 @@ def test_scalar_extraction():
# 0.1 not exactly representable in base 2 floating point.
repr_precision = len(repr(np.longdouble(0.1)))
# +2 from macro block starting around line 842 in scalartypes.c.src.
-@dec.skipif(LD_INFO.precision + 2 >= repr_precision,
- "repr precision not enough to show eps")
+@pytest.mark.skipif(LD_INFO.precision + 2 >= repr_precision,
+ reason="repr precision not enough to show eps")
def test_repr_roundtrip():
# We will only see eps in repr if within printing precision.
o = 1 + LD_INFO.eps
@@ -50,7 +50,7 @@ def test_bytes():
np.longdouble(b"1.2")
-@dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+@pytest.mark.skipif(string_to_longdouble_inaccurate, reason="Need strtold_l")
def test_repr_roundtrip_bytes():
o = 1 + LD_INFO.eps
assert_equal(np.longdouble(repr(o).encode("ascii")), o)
@@ -61,7 +61,7 @@ def test_bogus_string():
assert_raises(ValueError, np.longdouble, "1.0 flub")
-@dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+@pytest.mark.skipif(string_to_longdouble_inaccurate, reason="Need strtold_l")
def test_fromstring():
o = 1 + LD_INFO.eps
s = (" " + repr(o))*5
@@ -98,7 +98,8 @@ class TestFileBased(object):
res = np.fromfile(path, dtype=float, sep=" ")
assert_equal(res, np.array([1., 2., 3.]))
- @dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+ @pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_fromfile(self):
with temppath() as path:
with open(path, 'wt') as f:
@@ -106,7 +107,8 @@ class TestFileBased(object):
res = np.fromfile(path, dtype=np.longdouble, sep="\n")
assert_equal(res, self.tgt)
- @dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+ @pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_genfromtxt(self):
with temppath() as path:
with open(path, 'wt') as f:
@@ -114,7 +116,8 @@ class TestFileBased(object):
res = np.genfromtxt(path, dtype=np.longdouble)
assert_equal(res, self.tgt)
- @dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+ @pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_loadtxt(self):
with temppath() as path:
with open(path, 'wt') as f:
@@ -122,7 +125,8 @@ class TestFileBased(object):
res = np.loadtxt(path, dtype=np.longdouble)
assert_equal(res, self.tgt)
- @dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+ @pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_tofile_roundtrip(self):
with temppath() as path:
self.tgt.tofile(path, sep=" ")
@@ -138,22 +142,26 @@ def test_repr_exact():
assert_(repr(o) != '1')
-@dec.knownfailureif(longdouble_longer_than_double, "BUG #2376")
-@dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+@pytest.mark.skipif(longdouble_longer_than_double, reason="BUG #2376")
+@pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_format():
o = 1 + LD_INFO.eps
assert_("{0:.40g}".format(o) != '1')
-@dec.knownfailureif(longdouble_longer_than_double, "BUG #2376")
-@dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+@pytest.mark.skipif(longdouble_longer_than_double, reason="BUG #2376")
+@pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_percent():
o = 1 + LD_INFO.eps
assert_("%.40g" % o != '1')
-@dec.knownfailureif(longdouble_longer_than_double, "array repr problem")
-@dec.knownfailureif(string_to_longdouble_inaccurate, "Need strtold_l")
+@pytest.mark.skipif(longdouble_longer_than_double,
+ reason="array repr problem")
+@pytest.mark.skipif(string_to_longdouble_inaccurate,
+ reason="Need strtold_l")
def test_array_repr():
o = 1 + LD_INFO.eps
a = np.array([o])
diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py
index 92baa0896..076dc7c11 100644
--- a/numpy/core/tests/test_mem_overlap.py
+++ b/numpy/core/tests/test_mem_overlap.py
@@ -2,15 +2,17 @@ from __future__ import division, absolute_import, print_function
import sys
import itertools
+import pytest
import numpy as np
-from numpy.testing import (run_module_suite, assert_, assert_raises, assert_equal,
- assert_array_equal, assert_allclose, dec)
-
from numpy.core._multiarray_tests import solve_diophantine, internal_overlap
from numpy.core import _umath_tests
from numpy.lib.stride_tricks import as_strided
from numpy.compat import long
+from numpy.testing import (
+ run_module_suite, assert_, assert_raises, assert_equal, assert_array_equal,
+ assert_allclose
+ )
if sys.version_info[0] >= 3:
xrange = range
@@ -97,7 +99,7 @@ def test_overlapping_assignments():
_check_assignment(srcidx, dstidx)
-@dec.slow
+@pytest.mark.slow
def test_diophantine_fuzz():
# Fuzz test the diophantine solver
rng = np.random.RandomState(1234)
@@ -374,7 +376,7 @@ def check_may_share_memory_easy_fuzz(get_max_work, same_steps, min_count):
infeasible += 1
-@dec.slow
+@pytest.mark.slow
def test_may_share_memory_easy_fuzz():
# Check that overlap problems with common strides are always
# solved with little work.
@@ -384,7 +386,7 @@ def test_may_share_memory_easy_fuzz():
min_count=2000)
-@dec.slow
+@pytest.mark.slow
def test_may_share_memory_harder_fuzz():
# Overlap problems with not necessarily common strides take more
# work.
@@ -686,7 +688,7 @@ class TestUFunc(object):
# Check result
assert_copy_equivalent(operation, [a], out=b_out, axis=axis)
- @dec.slow
+ @pytest.mark.slow
def test_unary_ufunc_call_fuzz(self):
self.check_unary_fuzz(np.invert, None, np.int16)
@@ -897,7 +899,7 @@ class TestUFunc(object):
check(x, x.copy(), x)
check(x, x, x.copy())
- @dec.slow
+ @pytest.mark.slow
def test_binary_ufunc_1d_manual(self):
ufunc = np.add
diff --git a/numpy/core/tests/test_memmap.py b/numpy/core/tests/test_memmap.py
index c00867ce1..d6224ed02 100644
--- a/numpy/core/tests/test_memmap.py
+++ b/numpy/core/tests/test_memmap.py
@@ -3,8 +3,9 @@ from __future__ import division, absolute_import, print_function
import sys
import os
import shutil
-from tempfile import NamedTemporaryFile, TemporaryFile, mktemp, mkdtemp
import mmap
+import pytest
+from tempfile import NamedTemporaryFile, TemporaryFile, mktemp, mkdtemp
from numpy import (
memmap, sum, average, product, ndarray, isscalar, add, subtract, multiply)
@@ -13,7 +14,7 @@ from numpy.compat import Path
from numpy import arange, allclose, asarray
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
- dec, suppress_warnings
+ suppress_warnings
)
class TestMemmap(object):
@@ -76,7 +77,7 @@ class TestMemmap(object):
del b
del fp
- @dec.skipif(Path is None, "No pathlib.Path")
+ @pytest.mark.skipif(Path is None, reason="No pathlib.Path")
def test_path(self):
tmpname = mktemp('', 'mmap', dir=self.tempdir)
fp = memmap(Path(tmpname), dtype=self.dtype, mode='w+',
@@ -94,7 +95,8 @@ class TestMemmap(object):
shape=self.shape)
assert_equal(fp.filename, self.tmpfp.name)
- @dec.knownfailureif(sys.platform == 'gnu0', "This test is known to fail on hurd")
+ @pytest.mark.skipif(sys.platform == 'gnu0',
+ reason="Known to fail on hurd")
def test_flush(self):
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',
shape=self.shape)
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index d861da4b6..31d7bd2d0 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -17,6 +17,7 @@ import functools
import ctypes
import os
import gc
+import pytest
from contextlib import contextmanager
if sys.version_info[0] >= 3:
import builtins
@@ -31,7 +32,7 @@ from numpy.testing import (
run_module_suite, assert_, assert_raises, assert_warns,
assert_equal, assert_almost_equal, assert_array_equal, assert_raises_regex,
assert_array_almost_equal, assert_allclose, IS_PYPY, HAS_REFCOUNT,
- assert_array_less, runstring, dec, SkipTest, temppath, suppress_warnings
+ assert_array_less, runstring, SkipTest, temppath, suppress_warnings
)
from ._locales import CommaDecimalPointLocale
@@ -726,7 +727,7 @@ class TestCreation(object):
d = np.zeros(2, dtype='(2,4)i4, (2,4)i4')
assert_equal(np.count_nonzero(d), 0)
- @dec.slow
+ @pytest.mark.slow
def test_zeros_big(self):
# test big array as they might be allocated different by the system
types = np.typecodes['AllInteger'] + np.typecodes['AllFloat']
@@ -797,7 +798,7 @@ class TestCreation(object):
assert_equal(np.array([[1j, 1j],[1, 1]]).dtype, complex)
assert_equal(np.array([[1, 1, 1],[1, 1j, 1.], [1, 1, 1]]).dtype, complex)
- @dec.skipif(sys.version_info[0] >= 3)
+ @pytest.mark.skipif(sys.version_info[0] >= 3, reason="Not Python 2")
def test_sequence_long(self):
assert_equal(np.array([long(4), long(4)]).dtype, np.long)
assert_equal(np.array([long(4), 2**80]).dtype, object)
@@ -1216,7 +1217,7 @@ class TestBool(object):
# covers most cases of the 16 byte unrolled code
self.check_count_nonzero(12, 17)
- @dec.slow
+ @pytest.mark.slow
def test_count_nonzero_all(self):
# check all combinations in a length 17 array
# covers all cases of the 16 byte unrolled code
@@ -1255,11 +1256,11 @@ class TestBool(object):
def test_cast_from_void(self):
self._test_cast_from_flexible(np.void)
- @dec.knownfailureif(True, "See gh-9847")
+ @pytest.mark.xfail(reason="See gh-9847")
def test_cast_from_unicode(self):
self._test_cast_from_flexible(np.unicode_)
- @dec.knownfailureif(True, "See gh-9847")
+ @pytest.mark.xfail(reason="See gh-9847")
def test_cast_from_bytes(self):
self._test_cast_from_flexible(np.bytes_)
@@ -4385,7 +4386,7 @@ class TestIO(object):
np.array([1, 2, 3, 4]),
dtype='<f4')
- @dec.slow # takes > 1 minute on mechanical hard drive
+ @pytest.mark.slow # takes > 1 minute on mechanical hard drive
def test_big_binary(self):
"""Test workarounds for 32-bit limited fwrite, fseek, and ftell
calls in windows. These normally would hang doing something like this.
diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py
index 9d8f4f06a..50bcd4508 100644
--- a/numpy/core/tests/test_nditer.py
+++ b/numpy/core/tests/test_nditer.py
@@ -2,13 +2,14 @@ from __future__ import division, absolute_import, print_function
import sys
import warnings
+import pytest
import numpy as np
import numpy.core._multiarray_tests as _multiarray_tests
from numpy import array, arange, nditer, all
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
- assert_raises, assert_warns, dec, HAS_REFCOUNT, suppress_warnings
+ assert_raises, assert_warns, HAS_REFCOUNT, suppress_warnings
)
@@ -33,7 +34,7 @@ def iter_iterindices(i):
i.iternext()
return ret
-@dec._needs_refcount
+@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_iter_refcount():
# Make sure the iterator doesn't leak
@@ -2082,7 +2083,7 @@ def test_iter_buffering_growinner():
assert_equal(i[0].size, a.size)
-@dec.slow
+@pytest.mark.slow
def test_iter_buffered_reduce_reuse():
# large enough array for all views, including negative strides.
a = np.arange(2*3**5)[3**5:3**5+1]
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index d7cdd77f1..52eebdd02 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -4,6 +4,7 @@ import sys
import warnings
import itertools
import platform
+import pytest
from decimal import Decimal
import numpy as np
@@ -12,7 +13,7 @@ from numpy.random import rand, randint, randn
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_raises,
assert_raises_regex, assert_array_equal, assert_almost_equal,
- assert_array_almost_equal, dec, suppress_warnings
+ assert_array_almost_equal, suppress_warnings, HAS_REFCOUNT
)
@@ -467,7 +468,7 @@ class TestSeterr(object):
np.seterr(**old)
assert_(np.geterr() == old)
- @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
+ @pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
def test_divide_err(self):
with np.errstate(divide='raise'):
try:
@@ -551,7 +552,7 @@ class TestFloatExceptions(object):
self.assert_raises_fpe(fpeerr, flop, sc1, sc2[()])
self.assert_raises_fpe(fpeerr, flop, sc1[()], sc2[()])
- @dec.knownfailureif(True, "See ticket #2350")
+ @pytest.mark.xfail(reason="See ticket #2350")
def test_floating_exceptions(self):
# Test basic arithmetic function errors
with np.errstate(all='raise'):
@@ -2092,7 +2093,7 @@ class TestCreationFuncs(object):
self.check_function(np.full, 0)
self.check_function(np.full, 1)
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_for_reference_leak(self):
# Make sure we have an object for reference
dim = 1
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py
index f432711a9..b8b2581f3 100644
--- a/numpy/core/tests/test_print.py
+++ b/numpy/core/tests/test_print.py
@@ -1,14 +1,11 @@
from __future__ import division, absolute_import, print_function
import sys
-import locale
-import contextlib
-import nose
import numpy as np
from numpy.testing import (
- run_module_suite, assert_, assert_equal, SkipTest, dec
-)
+ run_module_suite, assert_, assert_equal, SkipTest
+ )
from ._locales import CommaDecimalPointLocale
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 016b720f3..ae1ee7e52 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -7,6 +7,7 @@ import platform
import gc
import warnings
import tempfile
+import pytest
from os import path
from io import BytesIO
from itertools import chain
@@ -15,7 +16,7 @@ import numpy as np
from numpy.testing import (
run_module_suite, assert_, assert_equal, IS_PYPY,
assert_almost_equal, assert_array_equal, assert_array_almost_equal,
- assert_raises, assert_warns, dec, suppress_warnings,
+ assert_raises, assert_warns, suppress_warnings,
_assert_valid_refcount, HAS_REFCOUNT,
)
from numpy.compat import asbytes, asunicode, long
@@ -600,7 +601,8 @@ class TestRegression(object):
# Cannot test if NPY_RELAXED_STRIDES_CHECKING changes the strides.
# With NPY_RELAXED_STRIDES_CHECKING the test becomes superfluous.
- @dec.skipif(np.ones(1).strides[0] == np.iinfo(np.intp).max)
+ @pytest.mark.skipif(np.ones(1).strides[0] == np.iinfo(np.intp).max,
+ reason="Using relaxed stride checking")
def test_reshape_trailing_ones_strides(self):
# GitHub issue gh-2949, bad strides for trailing ones of new shape
a = np.zeros(12, dtype=np.int32)[::2] # not contiguous
@@ -859,7 +861,8 @@ class TestRegression(object):
# Cannot test if NPY_RELAXED_STRIDES_CHECKING changes the strides.
# With NPY_RELAXED_STRIDES_CHECKING the test becomes superfluous,
# 0-sized reshape itself is tested elsewhere.
- @dec.skipif(np.ones(1).strides[0] == np.iinfo(np.intp).max)
+ @pytest.mark.skipif(np.ones(1).strides[0] == np.iinfo(np.intp).max,
+ reason="Using relaxed stride checking")
def test_copy_detection_corner_case2(self):
# Ticket #771: strides are not set correctly when reshaping 0-sized
# arrays
@@ -1424,7 +1427,7 @@ class TestRegression(object):
x[x.nonzero()] = x.ravel()[:1]
assert_(x[0, 1] == x[0, 0])
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_structured_arrays_with_objects2(self):
# Ticket #1299 second test
stra = 'aaaa'
@@ -1537,7 +1540,7 @@ class TestRegression(object):
y = np.add(x, x, x)
assert_equal(id(x), id(y))
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_take_refcount(self):
# ticket #939
a = np.arange(16, dtype=float)
@@ -1937,7 +1940,7 @@ class TestRegression(object):
a = np.empty((100000000,), dtype='i1')
del a
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_ufunc_reduce_memoryleak(self):
a = np.arange(6)
acnt = sys.getrefcount(a)
@@ -2167,7 +2170,7 @@ class TestRegression(object):
assert_equal(uf(a), ())
assert_array_equal(a, [[3, 2, 1], [5, 4], [9, 7, 8, 6]])
- @dec._needs_refcount
+ @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_leak_in_structured_dtype_comparison(self):
# gh-6250
recordtype = np.dtype([('a', np.float64),
diff --git a/numpy/core/tests/test_scalar_ctors.py b/numpy/core/tests/test_scalar_ctors.py
index e2470779b..3ae5e025f 100644
--- a/numpy/core/tests/test_scalar_ctors.py
+++ b/numpy/core/tests/test_scalar_ctors.py
@@ -5,13 +5,13 @@ from __future__ import division, absolute_import, print_function
import sys
import platform
-import numpy as np
+import pytest
+import numpy as np
from numpy.testing import (
- run_module_suite,
- assert_equal, assert_almost_equal, assert_raises, assert_warns,
- dec
-)
+ run_module_suite, assert_equal, assert_almost_equal, assert_raises,
+ assert_warns,
+ )
class TestFromString(object):
def test_floating(self):
@@ -43,11 +43,11 @@ class TestFromString(object):
flongdouble = assert_warns(RuntimeWarning, np.longdouble, '-1e10000')
assert_equal(flongdouble, -np.inf)
- @dec.knownfailureif((sys.version_info[0] >= 3) or
- (sys.platform == "win32" and
- platform.architecture()[0] == "64bit"),
- "numpy.intp('0xff', 16) not supported on Py3, "
- "as it does not inherit from Python int")
+ @pytest.mark.skipif((sys.version_info[0] >= 3)
+ or (sys.platform == "win32"
+ and platform.architecture()[0] == "64bit"),
+ reason="numpy.intp('0xff', 16) not supported on Py3 "
+ "or 64 bit Windows")
def test_intp(self):
# Ticket #99
i_width = np.int_(0).nbytes*2 - 1
diff --git a/numpy/core/tests/test_scalarbuffer.py b/numpy/core/tests/test_scalarbuffer.py
index cd887f2fb..0f7aea9bc 100644
--- a/numpy/core/tests/test_scalarbuffer.py
+++ b/numpy/core/tests/test_scalarbuffer.py
@@ -3,7 +3,9 @@ Test scalar buffer interface adheres to PEP 3118
"""
import sys
import numpy as np
-from numpy.testing import run_module_suite, assert_, assert_equal, dec
+import pytest
+
+from numpy.testing import run_module_suite, assert_, assert_equal
# PEP3118 format strings for native (standard alignment and byteorder) types
scalars_and_codes = [
@@ -28,11 +30,10 @@ scalars_and_codes = [
]
+@pytest.mark.skipif(sys.version_info.major < 3,
+ reason="Python 2 scalars lack a buffer interface")
class TestScalarPEP3118(object):
- skip_if_no_buffer_interface = dec.skipif(sys.version_info.major < 3,
- "scalars do not implement buffer interface in Python 2")
- @skip_if_no_buffer_interface
def test_scalar_match_array(self):
for scalar, _ in scalars_and_codes:
x = scalar()
@@ -41,7 +42,6 @@ class TestScalarPEP3118(object):
mv_a = memoryview(a)
assert_equal(mv_x.format, mv_a.format)
- @skip_if_no_buffer_interface
def test_scalar_dim(self):
for scalar, _ in scalars_and_codes:
x = scalar()
@@ -52,14 +52,12 @@ class TestScalarPEP3118(object):
assert_equal(mv_x.strides, ())
assert_equal(mv_x.suboffsets, ())
- @skip_if_no_buffer_interface
def test_scalar_known_code(self):
for scalar, code in scalars_and_codes:
x = scalar()
mv_x = memoryview(x)
assert_equal(mv_x.format, code)
- @skip_if_no_buffer_interface
def test_void_scalar_structured_data(self):
dt = np.dtype([('name', np.unicode_, 16), ('grades', np.float64, (2,))])
x = np.array(('ndarray_scalar', (1.2, 3.0)), dtype=dt)[()]
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index 7d0be9cf7..6d3ea02c5 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -5,13 +5,14 @@ import warnings
import itertools
import operator
import platform
+import pytest
import numpy as np
from numpy.testing import (
run_module_suite,
assert_, assert_equal, assert_raises,
assert_almost_equal, assert_allclose, assert_array_equal,
- IS_PYPY, suppress_warnings, dec, _gen_alignment_data, assert_warns
+ IS_PYPY, suppress_warnings, _gen_alignment_data, assert_warns
)
types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
@@ -410,8 +411,7 @@ class TestConversion(object):
assert_raises(OverflowError, int, x)
assert_equal(len(sup.log), 1)
- @dec.knownfailureif(not IS_PYPY,
- "__int__ is not the same as int in cpython (gh-9972)")
+ @pytest.mark.skipif(not IS_PYPY, reason="Test is PyPy only (gh-9972)")
def test_int_from_infinite_longdouble___int__(self):
x = np.longdouble(np.inf)
assert_raises(OverflowError, x.__int__)
@@ -421,8 +421,10 @@ class TestConversion(object):
assert_raises(OverflowError, x.__int__)
assert_equal(len(sup.log), 1)
- @dec.knownfailureif(platform.machine().startswith("ppc64"))
- @dec.skipif(np.finfo(np.double) == np.finfo(np.longdouble))
+ @pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
+ reason="long double is same as double")
+ @pytest.mark.skipif(platform.machine().startswith("ppc64"),
+ reason="IBM double double")
def test_int_from_huge_longdouble(self):
# Produce a longdouble that would overflow a double,
# use exponent that avoids bug in Darwin pow function.
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index fe7768e53..9dc9f5f08 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -5,6 +5,7 @@ import platform
import warnings
import fnmatch
import itertools
+import pytest
import numpy.core.umath as ncu
from numpy.core import _umath_tests as ncu_tests
@@ -12,7 +13,7 @@ import numpy as np
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_raises,
assert_raises_regex, assert_array_equal, assert_almost_equal,
- assert_array_almost_equal, dec, assert_allclose, assert_no_warnings,
+ assert_array_almost_equal, assert_allclose, assert_no_warnings,
suppress_warnings, _gen_alignment_data,
)
@@ -2491,7 +2492,8 @@ class TestComplexFunctions(object):
for dtype in [np.complex64, np.complex_]:
self.check_loss_of_precision(dtype)
- @dec.knownfailureif(is_longdouble_finfo_bogus(), "Bogus long double finfo")
+ @pytest.mark.skipif(is_longdouble_finfo_bogus(),
+ reason="Bogus long double finfo")
def test_loss_of_precision_longcomplex(self):
self.check_loss_of_precision(np.longcomplex)
@@ -2611,14 +2613,19 @@ def _test_nextafter(t):
def test_nextafter():
return _test_nextafter(np.float64)
+
def test_nextafterf():
return _test_nextafter(np.float32)
-@dec.knownfailureif(sys.platform == 'win32',
- "Long double support buggy on win32, ticket 1664.")
+
+@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
+ reason="long double is same as double")
+@pytest.mark.skipif(platform.machine().startswith("ppc64"),
+ reason="IBM double double")
def test_nextafterl():
return _test_nextafter(np.longdouble)
+
def test_nextafter_0():
for t, direction in itertools.product(np.sctypes['float'], (1, -1)):
tiny = np.finfo(t).tiny
@@ -2643,8 +2650,11 @@ def test_spacing():
def test_spacingf():
return _test_spacing(np.float32)
-@dec.knownfailureif(sys.platform == 'win32',
- "Long double support buggy on win32, ticket 1664.")
+
+@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
+ reason="long double is same as double")
+@pytest.mark.skipif(platform.machine().startswith("ppc64"),
+ reason="IBM double double")
def test_spacingl():
return _test_spacing(np.longdouble)
diff --git a/numpy/core/tests/test_umath_complex.py b/numpy/core/tests/test_umath_complex.py
index 1b098a120..c5ab1b229 100644
--- a/numpy/core/tests/test_umath_complex.py
+++ b/numpy/core/tests/test_umath_complex.py
@@ -2,12 +2,13 @@ from __future__ import division, absolute_import, print_function
import sys
import platform
+import pytest
import numpy as np
import numpy.core.umath as ncu
from numpy.testing import (
run_module_suite, assert_raises, assert_equal, assert_array_equal,
- assert_almost_equal, dec
+ assert_almost_equal
)
# TODO: branch cuts (use Pauli code)
@@ -17,17 +18,17 @@ from numpy.testing import (
# At least on Windows the results of many complex functions are not conforming
# to the C99 standard. See ticket 1574.
# Ditto for Solaris (ticket 1642) and OS X on PowerPC.
+#FIXME: this will probably change when we require full C99 campatibility
with np.errstate(all='ignore'):
functions_seem_flaky = ((np.exp(complex(np.inf, 0)).imag != 0)
or (np.log(complex(np.NZERO, 0)).imag != np.pi))
# TODO: replace with a check on whether platform-provided C99 funcs are used
-skip_complex_tests = (not sys.platform.startswith('linux') or functions_seem_flaky)
+xfail_complex_tests = (not sys.platform.startswith('linux') or functions_seem_flaky)
+
+# TODO This can be xfail when the generator functions are got rid of.
+platform_skip = pytest.mark.skipif(xfail_complex_tests,
+ reason="Inadequate C99 complex support")
-def platform_skip(func):
- return dec.skipif(skip_complex_tests,
- "Numpy is using complex functions (e.g. sqrt) provided by your"
- "platform's C library. However, they do not seem to behave according"
- "to C99 -- so C99 tests are skipped.")(func)
class TestCexp(object):
@@ -120,14 +121,15 @@ class TestCexp(object):
# cexp(nan + nani) is nan + nani
yield check, f, np.nan, np.nan, np.nan, np.nan
- @dec.knownfailureif(True, "cexp(nan + 0I) is wrong on most implementations")
+ # TODO This can be xfail when the generator functions are got rid of.
+ @pytest.mark.skip(reason="cexp(nan + 0I) is wrong on most platforms")
def test_special_values2(self):
# XXX: most implementations get it wrong here (including glibc <= 2.10)
# cexp(nan + 0i) is nan + 0i
check = check_complex_value
f = np.exp
- yield check, f, np.nan, 0, np.nan, 0
+ check(f, np.nan, 0, np.nan, 0)
class TestClog(object):
def test_simple(self):
@@ -138,7 +140,7 @@ class TestClog(object):
assert_almost_equal(y[i], y_r[i])
@platform_skip
- @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
+ @pytest.mark.skipif(platform.machine() == "armv5tel", reason="See gh-413.")
def test_special_values(self):
xl = []
yl = []
@@ -460,32 +462,33 @@ class TestCarg(object):
check_real_value(ncu._arg, 1, 1, 0.25*np.pi, False)
check_real_value(ncu._arg, np.PZERO, np.PZERO, np.PZERO)
- @dec.knownfailureif(True,
- "Complex arithmetic with signed zero is buggy on most implementation")
+ # TODO This can be xfail when the generator functions are got rid of.
+ @pytest.mark.skip(
+ reason="Complex arithmetic with signed zero fails on most platforms")
def test_zero(self):
# carg(-0 +- 0i) returns +- pi
- yield check_real_value, ncu._arg, np.NZERO, np.PZERO, np.pi, False
- yield check_real_value, ncu._arg, np.NZERO, np.NZERO, -np.pi, False
+ check_real_value(ncu._arg, np.NZERO, np.PZERO, np.pi, False)
+ check_real_value(ncu._arg, np.NZERO, np.NZERO, -np.pi, False)
# carg(+0 +- 0i) returns +- 0
- yield check_real_value, ncu._arg, np.PZERO, np.PZERO, np.PZERO
- yield check_real_value, ncu._arg, np.PZERO, np.NZERO, np.NZERO
+ check_real_value(ncu._arg, np.PZERO, np.PZERO, np.PZERO)
+ check_real_value(ncu._arg, np.PZERO, np.NZERO, np.NZERO)
# carg(x +- 0i) returns +- 0 for x > 0
- yield check_real_value, ncu._arg, 1, np.PZERO, np.PZERO, False
- yield check_real_value, ncu._arg, 1, np.NZERO, np.NZERO, False
+ check_real_value(ncu._arg, 1, np.PZERO, np.PZERO, False)
+ check_real_value(ncu._arg, 1, np.NZERO, np.NZERO, False)
# carg(x +- 0i) returns +- pi for x < 0
- yield check_real_value, ncu._arg, -1, np.PZERO, np.pi, False
- yield check_real_value, ncu._arg, -1, np.NZERO, -np.pi, False
+ check_real_value(ncu._arg, -1, np.PZERO, np.pi, False)
+ check_real_value(ncu._arg, -1, np.NZERO, -np.pi, False)
# carg(+- 0 + yi) returns pi/2 for y > 0
- yield check_real_value, ncu._arg, np.PZERO, 1, 0.5 * np.pi, False
- yield check_real_value, ncu._arg, np.NZERO, 1, 0.5 * np.pi, False
+ check_real_value(ncu._arg, np.PZERO, 1, 0.5 * np.pi, False)
+ check_real_value(ncu._arg, np.NZERO, 1, 0.5 * np.pi, False)
# carg(+- 0 + yi) returns -pi/2 for y < 0
- yield check_real_value, ncu._arg, np.PZERO, -1, 0.5 * np.pi, False
- yield check_real_value, ncu._arg, np.NZERO, -1, -0.5 * np.pi, False
+ check_real_value(ncu._arg, np.PZERO, -1, 0.5 * np.pi, False)
+ check_real_value(ncu._arg, np.NZERO, -1, -0.5 * np.pi, False)
#def test_branch_cuts(self):
# _check_branch_cut(ncu._arg, -1, 1j, -1, 1)