1363 строки
43 KiB
Diff
1363 строки
43 KiB
Diff
From 79643fcb92cc90b955f177f06bb6b342f1d3ef14 Mon Sep 17 00:00:00 2001
|
|
From: Osama Esmail <osamaesmail@microsoft.com>
|
|
Date: Mon, 14 Nov 2022 19:09:17 -0800
|
|
Subject: [PATCH 1/2] fixing the tests the way numpy PR 22487 does
|
|
|
|
---
|
|
doc/TESTS.rst.txt | 17 ++++---
|
|
numpy/core/tests/test_arrayprint.py | 4 +-
|
|
numpy/core/tests/test_defchararray.py | 20 ++++----
|
|
numpy/core/tests/test_deprecations.py | 8 ++--
|
|
numpy/core/tests/test_half.py | 2 +-
|
|
numpy/core/tests/test_indexing.py | 2 +-
|
|
numpy/core/tests/test_memmap.py | 4 +-
|
|
numpy/core/tests/test_multiarray.py | 18 ++++----
|
|
numpy/core/tests/test_numeric.py | 26 +++++------
|
|
numpy/core/tests/test_numerictypes.py | 2 +-
|
|
numpy/core/tests/test_overrides.py | 2 +-
|
|
numpy/core/tests/test_records.py | 2 +-
|
|
numpy/core/tests/test_umath.py | 4 +-
|
|
numpy/core/tests/test_umath_complex.py | 8 ++--
|
|
numpy/distutils/tests/test_ccompiler_opt.py | 4 +-
|
|
.../tests/test_ccompiler_opt_conf.py | 4 +-
|
|
numpy/distutils/tests/test_exec_command.py | 2 +-
|
|
numpy/distutils/tests/test_system_info.py | 4 +-
|
|
numpy/f2py/tests/test_assumed_shape.py | 6 +--
|
|
numpy/f2py/tests/util.py | 2 +-
|
|
numpy/lib/tests/test__datasource.py | 24 +++++-----
|
|
numpy/lib/tests/test_function_base.py | 2 +-
|
|
numpy/lib/tests/test_histograms.py | 4 +-
|
|
numpy/lib/tests/test_io.py | 5 +-
|
|
numpy/lib/tests/test_recfunctions.py | 12 ++---
|
|
numpy/ma/tests/test_core.py | 24 +++++-----
|
|
numpy/ma/tests/test_extras.py | 4 +-
|
|
numpy/ma/tests/test_mrecords.py | 2 +-
|
|
numpy/ma/tests/test_old_ma.py | 46 +++++++++----------
|
|
numpy/ma/tests/test_subclassing.py | 2 +-
|
|
numpy/matrixlib/tests/test_masked_matrix.py | 2 +-
|
|
numpy/random/tests/test_generator_mt19937.py | 12 ++---
|
|
numpy/random/tests/test_random.py | 10 ++--
|
|
numpy/random/tests/test_randomstate.py | 10 ++--
|
|
numpy/testing/tests/test_utils.py | 14 +++---
|
|
35 files changed, 159 insertions(+), 155 deletions(-)
|
|
|
|
diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt
|
|
index 0d8137f4a..9c5e8571f 100644
|
|
--- a/doc/TESTS.rst.txt
|
|
+++ b/doc/TESTS.rst.txt
|
|
@@ -178,30 +178,33 @@ Similarly for methods::
|
|
Easier setup and teardown functions / methods
|
|
---------------------------------------------
|
|
|
|
-Testing looks for module-level or class-level setup and teardown functions by
|
|
-name; thus::
|
|
+Testing looks for module-level or class method-level setup and teardown
|
|
+functions by name; thus::
|
|
|
|
- def setup():
|
|
+ def setup_module():
|
|
"""Module-level setup"""
|
|
print('doing setup')
|
|
|
|
- def teardown():
|
|
+ def teardown_module():
|
|
"""Module-level teardown"""
|
|
print('doing teardown')
|
|
|
|
|
|
class TestMe:
|
|
- def setup():
|
|
+ def setup_method(self):
|
|
"""Class-level setup"""
|
|
print('doing setup')
|
|
|
|
- def teardown():
|
|
+ def teardown_method():
|
|
"""Class-level teardown"""
|
|
print('doing teardown')
|
|
|
|
|
|
Setup and teardown functions to functions and methods are known as "fixtures",
|
|
-and their use is not encouraged.
|
|
+and they should be used sparingly.
|
|
+``pytest`` supports more general fixture at various scopes which may be used
|
|
+automatically via special arguments. For example, the special argument name
|
|
+``tmpdir`` is used in test to create a temporary directory.
|
|
|
|
Parametric tests
|
|
----------------
|
|
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
|
|
index 25826d8ed..1f5b7abdd 100644
|
|
--- a/numpy/core/tests/test_arrayprint.py
|
|
+++ b/numpy/core/tests/test_arrayprint.py
|
|
@@ -498,10 +498,10 @@ def test_refcount(self):
|
|
class TestPrintOptions:
|
|
"""Test getting and setting global print options."""
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.oldopts = np.get_printoptions()
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.set_printoptions(**self.oldopts)
|
|
|
|
def test_basic(self):
|
|
diff --git a/numpy/core/tests/test_defchararray.py b/numpy/core/tests/test_defchararray.py
|
|
index 59fc54722..64124903c 100644
|
|
--- a/numpy/core/tests/test_defchararray.py
|
|
+++ b/numpy/core/tests/test_defchararray.py
|
|
@@ -132,7 +132,7 @@ def fail():
|
|
|
|
|
|
class TestWhitespace:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([['abc ', '123 '],
|
|
['789 ', 'xyz ']]).view(np.chararray)
|
|
self.B = np.array([['abc', '123'],
|
|
@@ -147,7 +147,7 @@ def test1(self):
|
|
assert_(not np.any(self.A != self.B))
|
|
|
|
class TestChar:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array('abc1', dtype='c').view(np.chararray)
|
|
|
|
def test_it(self):
|
|
@@ -155,7 +155,7 @@ def test_it(self):
|
|
assert_equal(self.A.upper()[:2].tobytes(), b'AB')
|
|
|
|
class TestComparisons:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([['abc', '123'],
|
|
['789', 'xyz']]).view(np.chararray)
|
|
self.B = np.array([['efg', '123 '],
|
|
@@ -188,21 +188,21 @@ def test_type(self):
|
|
class TestComparisonsMixed1(TestComparisons):
|
|
"""Ticket #1276"""
|
|
|
|
- def setup(self):
|
|
- TestComparisons.setup(self)
|
|
+ def setup_method(self):
|
|
+ TestComparisons.setup_method(self)
|
|
self.B = np.array([['efg', '123 '],
|
|
['051', 'tuv']], np.unicode_).view(np.chararray)
|
|
|
|
class TestComparisonsMixed2(TestComparisons):
|
|
"""Ticket #1276"""
|
|
|
|
- def setup(self):
|
|
- TestComparisons.setup(self)
|
|
+ def setup_method(self):
|
|
+ TestComparisons.setup_method(self)
|
|
self.A = np.array([['abc', '123'],
|
|
['789', 'xyz']], np.unicode_).view(np.chararray)
|
|
|
|
class TestInformation:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([[' abc ', ''],
|
|
['12345', 'MixedCase'],
|
|
['123 \t 345 \0 ', 'UPPER']]).view(np.chararray)
|
|
@@ -308,7 +308,7 @@ def fail():
|
|
|
|
|
|
class TestMethods:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([[' abc ', ''],
|
|
['12345', 'MixedCase'],
|
|
['123 \t 345 \0 ', 'UPPER']],
|
|
@@ -581,7 +581,7 @@ def fail():
|
|
|
|
|
|
class TestOperations:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([['abc', '123'],
|
|
['789', 'xyz']]).view(np.chararray)
|
|
self.B = np.array([['efg', '456'],
|
|
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
|
|
index 2b7864433..d443edd13 100644
|
|
--- a/numpy/core/tests/test_deprecations.py
|
|
+++ b/numpy/core/tests/test_deprecations.py
|
|
@@ -32,7 +32,7 @@ class _DeprecationTestCase:
|
|
message = ''
|
|
warning_cls = DeprecationWarning
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.warn_ctx = warnings.catch_warnings(record=True)
|
|
self.log = self.warn_ctx.__enter__()
|
|
|
|
@@ -46,7 +46,7 @@ def setup(self):
|
|
warnings.filterwarnings("always", message=self.message,
|
|
category=self.warning_cls)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
self.warn_ctx.__exit__()
|
|
|
|
def assert_deprecated(self, function, num=1, ignore_others=False,
|
|
@@ -297,7 +297,7 @@ class vdt(np.void):
|
|
class TestTestDeprecated:
|
|
def test_assert_deprecated(self):
|
|
test_case_instance = _DeprecationTestCase()
|
|
- test_case_instance.setup()
|
|
+ test_case_instance.setup_method()
|
|
assert_raises(AssertionError,
|
|
test_case_instance.assert_deprecated,
|
|
lambda: None)
|
|
@@ -306,7 +306,7 @@ def foo():
|
|
warnings.warn("foo", category=DeprecationWarning, stacklevel=2)
|
|
|
|
test_case_instance.assert_deprecated(foo)
|
|
- test_case_instance.teardown()
|
|
+ test_case_instance.teardown_method()
|
|
|
|
|
|
class TestNonNumericConjugate(_DeprecationTestCase):
|
|
diff --git a/numpy/core/tests/test_half.py b/numpy/core/tests/test_half.py
|
|
index 1b6fd21e1..78bd068bb 100644
|
|
--- a/numpy/core/tests/test_half.py
|
|
+++ b/numpy/core/tests/test_half.py
|
|
@@ -17,7 +17,7 @@ def assert_raises_fpe(strmatch, callable, *args, **kwargs):
|
|
"Did not raise floating point %s error" % strmatch)
|
|
|
|
class TestHalf:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# An array of all possible float16 values
|
|
self.all_f16 = np.arange(0x10000, dtype=uint16)
|
|
self.all_f16.dtype = float16
|
|
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py
|
|
index efcb92c2e..7f22be503 100644
|
|
--- a/numpy/core/tests/test_indexing.py
|
|
+++ b/numpy/core/tests/test_indexing.py
|
|
@@ -826,7 +826,7 @@ class TestMultiIndexingAutomated:
|
|
|
|
"""
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.a = np.arange(np.prod([3, 1, 5, 6])).reshape(3, 1, 5, 6)
|
|
self.b = np.empty((3, 0, 5, 6))
|
|
self.complex_indices = ['skip', Ellipsis,
|
|
diff --git a/numpy/core/tests/test_memmap.py b/numpy/core/tests/test_memmap.py
|
|
index e4f0a6b3f..914f86f14 100644
|
|
--- a/numpy/core/tests/test_memmap.py
|
|
+++ b/numpy/core/tests/test_memmap.py
|
|
@@ -15,14 +15,14 @@
|
|
)
|
|
|
|
class TestMemmap:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpfp = NamedTemporaryFile(prefix='mmap')
|
|
self.shape = (3, 4)
|
|
self.dtype = 'float32'
|
|
self.data = arange(12, dtype=self.dtype)
|
|
self.data.resize(self.shape)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
self.tmpfp.close()
|
|
self.data = None
|
|
if IS_PYPY:
|
|
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
|
|
index cacfd5bfc..e5dee24c0 100644
|
|
--- a/numpy/core/tests/test_multiarray.py
|
|
+++ b/numpy/core/tests/test_multiarray.py
|
|
@@ -74,7 +74,7 @@ def _aligned_zeros(shape, dtype=float, order="C", align=None):
|
|
|
|
|
|
class TestFlags:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.a = np.arange(10)
|
|
|
|
def test_writeable(self):
|
|
@@ -275,7 +275,7 @@ def test_int(self):
|
|
|
|
|
|
class TestAttributes:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.one = np.arange(10)
|
|
self.two = np.arange(20).reshape(4, 5)
|
|
self.three = np.arange(60, dtype=np.float64).reshape(2, 5, 6)
|
|
@@ -652,7 +652,7 @@ def test_structured_non_void(self):
|
|
|
|
|
|
class TestZeroRank:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.d = np.array(0), np.array('x', object)
|
|
|
|
def test_ellipsis_subscript(self):
|
|
@@ -756,7 +756,7 @@ def test_real_imag(self):
|
|
|
|
|
|
class TestScalarIndexing:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.d = np.array([0, 1])[0]
|
|
|
|
def test_ellipsis_subscript(self):
|
|
@@ -5672,7 +5672,7 @@ def test_mmap_close(self):
|
|
mm.close()
|
|
|
|
class TestFlat:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
a0 = np.arange(20.0)
|
|
a = a0.reshape(4, 5)
|
|
a0.shape = (4, 5)
|
|
@@ -5995,7 +5995,7 @@ class TestStats:
|
|
|
|
funcs = [_mean, _var, _std]
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
np.random.seed(range(3))
|
|
self.rmat = np.random.random((4, 5))
|
|
self.cmat = self.rmat + 1j * self.rmat
|
|
@@ -6422,7 +6422,7 @@ def test_vdot_uncontiguous(self):
|
|
|
|
|
|
class TestDot:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
np.random.seed(128)
|
|
self.A = np.random.rand(4, 2)
|
|
self.b1 = np.random.rand(2, 1)
|
|
@@ -7214,7 +7214,7 @@ def test_3d_tensor(self):
|
|
|
|
|
|
class TestChoose:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.x = 2*np.ones((3,), dtype=int)
|
|
self.y = 3*np.ones((3,), dtype=int)
|
|
self.x2 = 2*np.ones((2, 3), dtype=int)
|
|
@@ -7244,7 +7244,7 @@ def test_output_dtype(self, ops):
|
|
|
|
|
|
class TestRepeat:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.m = np.array([1, 2, 3, 4, 5, 6])
|
|
self.m_rect = self.m.reshape((2, 3))
|
|
|
|
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
|
|
index 0b03c6576..692e4e0c6 100644
|
|
--- a/numpy/core/tests/test_numeric.py
|
|
+++ b/numpy/core/tests/test_numeric.py
|
|
@@ -347,7 +347,7 @@ def test_bitwise_xor(self):
|
|
|
|
|
|
class TestBoolArray:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# offset for simd tests
|
|
self.t = np.array([True] * 41, dtype=bool)[1::]
|
|
self.f = np.array([False] * 41, dtype=bool)[1::]
|
|
@@ -434,7 +434,7 @@ def test_logical_and_or_xor(self):
|
|
|
|
|
|
class TestBoolCmp:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.f = np.ones(256, dtype=np.float32)
|
|
self.ef = np.ones(self.f.size, dtype=bool)
|
|
self.d = np.ones(128, dtype=np.float64)
|
|
@@ -1813,7 +1813,7 @@ def assert_array_strict_equal(x, y):
|
|
|
|
|
|
class TestClip:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.nr = 5
|
|
self.nc = 3
|
|
|
|
@@ -2442,10 +2442,10 @@ class TestAllclose:
|
|
rtol = 1e-5
|
|
atol = 1e-8
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.olderr = np.seterr(invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.olderr)
|
|
|
|
def tst_allclose(self, x, y):
|
|
@@ -2527,7 +2527,7 @@ class TestIsclose:
|
|
rtol = 1e-5
|
|
atol = 1e-8
|
|
|
|
- def setup(self):
|
|
+ def _setup(self):
|
|
atol = self.atol
|
|
rtol = self.rtol
|
|
arr = np.array([100, 1000])
|
|
@@ -2573,7 +2573,7 @@ def setup(self):
|
|
]
|
|
|
|
def test_ip_isclose(self):
|
|
- self.setup()
|
|
+ self._setup()
|
|
tests = self.some_close_tests
|
|
results = self.some_close_results
|
|
for (x, y), result in zip(tests, results):
|
|
@@ -2595,17 +2595,17 @@ def tst_isclose_allclose(self, x, y):
|
|
assert_array_equal(np.isclose(x, y).all(), np.allclose(x, y), msg % (x, y))
|
|
|
|
def test_ip_all_isclose(self):
|
|
- self.setup()
|
|
+ self._setup()
|
|
for (x, y) in self.all_close_tests:
|
|
self.tst_all_isclose(x, y)
|
|
|
|
def test_ip_none_isclose(self):
|
|
- self.setup()
|
|
+ self._setup()
|
|
for (x, y) in self.none_close_tests:
|
|
self.tst_none_isclose(x, y)
|
|
|
|
def test_ip_isclose_allclose(self):
|
|
- self.setup()
|
|
+ self._setup()
|
|
tests = (self.all_close_tests + self.none_close_tests +
|
|
self.some_close_tests)
|
|
for (x, y) in tests:
|
|
@@ -2671,7 +2671,7 @@ def test_timedelta(self):
|
|
|
|
|
|
class TestStdVar:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.A = np.array([1, -1, 1, -1])
|
|
self.real_var = 1
|
|
|
|
@@ -2724,7 +2724,7 @@ def test_scalars(self):
|
|
class TestCreationFuncs:
|
|
# Test ones, zeros, empty and full.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
dtypes = {np.dtype(tp) for tp in itertools.chain(*np.sctypes.values())}
|
|
# void, bytes, str
|
|
variable_sized = {tp for tp in dtypes if tp.str.endswith('0')}
|
|
@@ -2795,7 +2795,7 @@ def test_for_reference_leak(self):
|
|
class TestLikeFuncs:
|
|
'''Test ones_like, zeros_like, empty_like and full_like'''
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.data = [
|
|
# Array scalars
|
|
(np.array(3.), None),
|
|
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
|
|
index 73ff4764d..e5ff52332 100644
|
|
--- a/numpy/core/tests/test_numerictypes.py
|
|
+++ b/numpy/core/tests/test_numerictypes.py
|
|
@@ -357,7 +357,7 @@ def test_scalar_wins3(self): # doesn't go up to 'f16' on purpose
|
|
assert_(res == 'f8')
|
|
|
|
class TestMultipleFields:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.ary = np.array([(1, 2, 3, 4), (5, 6, 7, 8)], dtype='i4,f4,i2,c8')
|
|
|
|
def _bad_call(self):
|
|
diff --git a/numpy/core/tests/test_overrides.py b/numpy/core/tests/test_overrides.py
|
|
index 36970dbc0..105645027 100644
|
|
--- a/numpy/core/tests/test_overrides.py
|
|
+++ b/numpy/core/tests/test_overrides.py
|
|
@@ -431,7 +431,7 @@ def __array_function__(self, func, types, args, kwargs):
|
|
|
|
|
|
class TestArrayLike:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
class MyArray():
|
|
def __init__(self, function=None):
|
|
self.function = function
|
|
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
|
|
index 4d4b4b515..a76ae2d99 100644
|
|
--- a/numpy/core/tests/test_records.py
|
|
+++ b/numpy/core/tests/test_records.py
|
|
@@ -337,7 +337,7 @@ def test_tofile_fromfile(self):
|
|
|
|
|
|
class TestRecord:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.data = np.rec.fromrecords([(1, 2, 3), (4, 5, 6)],
|
|
dtype=[("col1", "<i4"),
|
|
("col2", "<i4"),
|
|
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
|
|
index 4d17a8f35..d0550e195 100644
|
|
--- a/numpy/core/tests/test_umath.py
|
|
+++ b/numpy/core/tests/test_umath.py
|
|
@@ -103,10 +103,10 @@ def bad_arcsinh():
|
|
|
|
|
|
class _FilterInvalids:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.olderr = np.seterr(invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.olderr)
|
|
|
|
|
|
diff --git a/numpy/core/tests/test_umath_complex.py b/numpy/core/tests/test_umath_complex.py
|
|
index af5bbe59e..8aa9a28ff 100644
|
|
--- a/numpy/core/tests/test_umath_complex.py
|
|
+++ b/numpy/core/tests/test_umath_complex.py
|
|
@@ -354,10 +354,10 @@ def _check_ninf_nan(dummy):
|
|
# cuts first)
|
|
|
|
class TestCpow:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.olderr = np.seterr(invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.olderr)
|
|
|
|
def test_simple(self):
|
|
@@ -407,10 +407,10 @@ def test_array(self):
|
|
assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
|
|
|
|
class TestCabs:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.olderr = np.seterr(invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.olderr)
|
|
|
|
def test_simple(self):
|
|
diff --git a/numpy/distutils/tests/test_ccompiler_opt.py b/numpy/distutils/tests/test_ccompiler_opt.py
|
|
index 1ca8bc09b..657ebdb68 100644
|
|
--- a/numpy/distutils/tests/test_ccompiler_opt.py
|
|
+++ b/numpy/distutils/tests/test_ccompiler_opt.py
|
|
@@ -78,7 +78,7 @@ class _Test_CCompilerOpt:
|
|
arch = None # x86_64
|
|
cc = None # gcc
|
|
|
|
- def setup(self):
|
|
+ def setup_class(self):
|
|
FakeCCompilerOpt.conf_nocache = True
|
|
self._opt = None
|
|
|
|
@@ -780,7 +780,7 @@ class TestCCompilerOpt_{class_name}(_Test_CCompilerOpt, unittest.TestCase):
|
|
cc = '{cc}'
|
|
def __init__(self, methodName="runTest"):
|
|
unittest.TestCase.__init__(self, methodName)
|
|
- self.setup()
|
|
+ self.setup_class()
|
|
""").format(
|
|
class_name=arch + '_' + cc, arch=arch, cc=cc
|
|
)
|
|
diff --git a/numpy/distutils/tests/test_ccompiler_opt_conf.py b/numpy/distutils/tests/test_ccompiler_opt_conf.py
|
|
index 09c1fad40..d9e8b2b0a 100644
|
|
--- a/numpy/distutils/tests/test_ccompiler_opt_conf.py
|
|
+++ b/numpy/distutils/tests/test_ccompiler_opt_conf.py
|
|
@@ -161,9 +161,9 @@ def test_extra_checks(self, error_msg, search_in, feature_name, feature_dict):
|
|
class TestConfFeatures(unittest.TestCase):
|
|
def __init__(self, methodName="runTest"):
|
|
unittest.TestCase.__init__(self, methodName)
|
|
- self.setup()
|
|
+ self._setup()
|
|
|
|
- def setup(self):
|
|
+ def _setup(self):
|
|
FakeCCompilerOpt.conf_nocache = True
|
|
|
|
def test_features(self):
|
|
diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py
|
|
index d6eb7d1c3..157bd8427 100644
|
|
--- a/numpy/distutils/tests/test_exec_command.py
|
|
+++ b/numpy/distutils/tests/test_exec_command.py
|
|
@@ -94,7 +94,7 @@ def test_exec_command_stderr():
|
|
|
|
|
|
class TestExecCommand:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.pyexe = get_pythonexe()
|
|
|
|
def check_nt(self, **kws):
|
|
diff --git a/numpy/distutils/tests/test_system_info.py b/numpy/distutils/tests/test_system_info.py
|
|
index 8c26271af..539badf07 100644
|
|
--- a/numpy/distutils/tests/test_system_info.py
|
|
+++ b/numpy/distutils/tests/test_system_info.py
|
|
@@ -130,7 +130,7 @@ class DuplicateOptionInfo(_system_info):
|
|
|
|
class TestSystemInfoReading:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
""" Create the libraries """
|
|
# Create 2 sources and 2 libraries
|
|
self._dir1 = mkdtemp()
|
|
@@ -172,7 +172,7 @@ def site_and_parse(c, site_cfg):
|
|
self._sitecfg)
|
|
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
# Do each removal separately
|
|
try:
|
|
shutil.rmtree(self._dir1)
|
|
diff --git a/numpy/f2py/tests/test_assumed_shape.py b/numpy/f2py/tests/test_assumed_shape.py
|
|
index e546c379b..d4664cf88 100644
|
|
--- a/numpy/f2py/tests/test_assumed_shape.py
|
|
+++ b/numpy/f2py/tests/test_assumed_shape.py
|
|
@@ -30,7 +30,7 @@ def test_all(self):
|
|
|
|
|
|
class TestF2cmapOption(TestAssumedShapeSumExample):
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Use a custom file name for .f2py_f2cmap
|
|
self.sources = list(self.sources)
|
|
f2cmap_src = self.sources.pop(-1)
|
|
@@ -43,7 +43,7 @@ def setup(self):
|
|
self.sources.append(self.f2cmap_file.name)
|
|
self.options = ["--f2cmap", self.f2cmap_file.name]
|
|
|
|
- super().setup()
|
|
+ super().setup_method()
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
os.unlink(self.f2cmap_file.name)
|
|
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
|
|
index ae81bbfc4..620ea9110 100644
|
|
--- a/numpy/f2py/tests/util.py
|
|
+++ b/numpy/f2py/tests/util.py
|
|
@@ -334,7 +334,7 @@ class F2PyTest:
|
|
module = None
|
|
module_name = None
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
if sys.platform == "win32":
|
|
pytest.skip("Fails with MinGW64 Gfortran (Issue #9673)")
|
|
|
|
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py
|
|
index 2738d41c4..c8149abc3 100644
|
|
--- a/numpy/lib/tests/test__datasource.py
|
|
+++ b/numpy/lib/tests/test__datasource.py
|
|
@@ -87,11 +87,11 @@ def invalid_httpfile():
|
|
|
|
|
|
class TestDataSourceOpen:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = mkdtemp()
|
|
self.ds = datasource.DataSource(self.tmpdir)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
del self.ds
|
|
|
|
@@ -156,11 +156,11 @@ def test_ValidBz2File(self):
|
|
|
|
|
|
class TestDataSourceExists:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = mkdtemp()
|
|
self.ds = datasource.DataSource(self.tmpdir)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
del self.ds
|
|
|
|
@@ -186,11 +186,11 @@ def test_InvalidFile(self):
|
|
|
|
|
|
class TestDataSourceAbspath:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = os.path.abspath(mkdtemp())
|
|
self.ds = datasource.DataSource(self.tmpdir)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
del self.ds
|
|
|
|
@@ -251,11 +251,11 @@ def test_windows_os_sep(self):
|
|
|
|
|
|
class TestRepositoryAbspath:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = os.path.abspath(mkdtemp())
|
|
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
del self.repos
|
|
|
|
@@ -284,11 +284,11 @@ def test_windows_os_sep(self):
|
|
|
|
|
|
class TestRepositoryExists:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = mkdtemp()
|
|
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
del self.repos
|
|
|
|
@@ -317,10 +317,10 @@ def test_CachedHTTPFile(self):
|
|
|
|
|
|
class TestOpenFunc:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.tmpdir = mkdtemp()
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
rmtree(self.tmpdir)
|
|
|
|
def test_DataSourceOpen(self):
|
|
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
|
|
index 865b91965..f4370e5ff 100644
|
|
--- a/numpy/lib/tests/test_function_base.py
|
|
+++ b/numpy/lib/tests/test_function_base.py
|
|
@@ -845,7 +845,7 @@ def test_append(self):
|
|
|
|
class TestDelete:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.a = np.arange(5)
|
|
self.nd_a = np.arange(5).repeat(2).reshape(1, 5, 2)
|
|
|
|
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py
|
|
index fc16b7396..1a1327c84 100644
|
|
--- a/numpy/lib/tests/test_histograms.py
|
|
+++ b/numpy/lib/tests/test_histograms.py
|
|
@@ -11,10 +11,10 @@
|
|
|
|
class TestHistogram:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
pass
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
pass
|
|
|
|
def test_simple(self):
|
|
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
|
|
index dde48ccae..dac09e1a3 100644
|
|
--- a/numpy/lib/tests/test_io.py
|
|
+++ b/numpy/lib/tests/test_io.py
|
|
@@ -685,11 +685,12 @@ def test_converters_nodecode(self):
|
|
class TestLoadTxt(LoadTxtBase):
|
|
loadfunc = staticmethod(np.loadtxt)
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# lower chunksize for testing
|
|
self.orig_chunk = np.lib.npyio._loadtxt_chunksize
|
|
np.lib.npyio._loadtxt_chunksize = 1
|
|
- def teardown(self):
|
|
+
|
|
+ def teardown_method(self):
|
|
np.lib.npyio._loadtxt_chunksize = self.orig_chunk
|
|
|
|
def test_record(self):
|
|
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
|
|
index 9b2506a7c..3746de656 100644
|
|
--- a/numpy/lib/tests/test_recfunctions.py
|
|
+++ b/numpy/lib/tests/test_recfunctions.py
|
|
@@ -20,7 +20,7 @@
|
|
class TestRecFunctions:
|
|
# Misc tests
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1, 2, ])
|
|
y = np.array([10, 20, 30])
|
|
z = np.array([('A', 1.), ('B', 2.)],
|
|
@@ -372,7 +372,7 @@ def test_masked_flexible(self):
|
|
class TestMergeArrays:
|
|
# Test merge_arrays
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1, 2, ])
|
|
y = np.array([10, 20, 30])
|
|
z = np.array(
|
|
@@ -505,7 +505,7 @@ def test_singlerecord(self):
|
|
class TestAppendFields:
|
|
# Test append_fields
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1, 2, ])
|
|
y = np.array([10, 20, 30])
|
|
z = np.array(
|
|
@@ -558,7 +558,7 @@ def test_append_on_nested(self):
|
|
|
|
class TestStackArrays:
|
|
# Test stack_arrays
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1, 2, ])
|
|
y = np.array([10, 20, 30])
|
|
z = np.array(
|
|
@@ -728,7 +728,7 @@ def test_subdtype(self):
|
|
|
|
|
|
class TestJoinBy:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
|
|
np.arange(100, 110))),
|
|
dtype=[('a', int), ('b', int), ('c', int)])
|
|
@@ -962,7 +962,7 @@ class TestAppendFieldsObj:
|
|
"""
|
|
# https://github.com/numpy/numpy/issues/2346
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
from datetime import date
|
|
self.data = dict(obj=date(2000, 1, 1))
|
|
|
|
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
|
|
index c8f7f4269..e8cfb5b0c 100644
|
|
--- a/numpy/ma/tests/test_core.py
|
|
+++ b/numpy/ma/tests/test_core.py
|
|
@@ -66,7 +66,7 @@
|
|
class TestMaskedArray:
|
|
# Base test class for MaskedArrays.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
|
|
y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
|
|
@@ -997,7 +997,7 @@ def test_object_with_array(self):
|
|
class TestMaskedArrayArithmetic:
|
|
# Base test class for MaskedArrays.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
|
|
y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
|
|
@@ -1014,7 +1014,7 @@ def setup(self):
|
|
self.err_status = np.geterr()
|
|
np.seterr(divide='ignore', invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.err_status)
|
|
|
|
def test_basic_arithmetic(self):
|
|
@@ -2338,14 +2338,14 @@ def test_fillvalue_bytes_or_str(self):
|
|
class TestUfuncs:
|
|
# Test class for the application of ufuncs on MaskedArrays.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6),
|
|
array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),)
|
|
self.err_status = np.geterr()
|
|
np.seterr(divide='ignore', invalid='ignore')
|
|
|
|
- def teardown(self):
|
|
+ def teardown_method(self):
|
|
np.seterr(**self.err_status)
|
|
|
|
def test_testUfuncRegression(self):
|
|
@@ -2482,7 +2482,7 @@ def test_no_masked_nan_warnings(self):
|
|
class TestMaskedArrayInPlaceArithmetic:
|
|
# Test MaskedArray Arithmetic
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = arange(10)
|
|
y = arange(10)
|
|
xm = arange(10)
|
|
@@ -2995,7 +2995,7 @@ def test_inplace_pow_type(self):
|
|
|
|
class TestMaskedArrayMethods:
|
|
# Test class for miscellaneous MaskedArrays methods.
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
x = np.array([8.375, 7.545, 8.828, 8.5, 1.757, 5.928,
|
|
8.43, 7.78, 9.865, 5.878, 8.979, 4.732,
|
|
@@ -3757,7 +3757,7 @@ def test_diagonal_view(self):
|
|
|
|
class TestMaskedArrayMathMethods:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
x = np.array([8.375, 7.545, 8.828, 8.5, 1.757, 5.928,
|
|
8.43, 7.78, 9.865, 5.878, 8.979, 4.732,
|
|
@@ -4057,7 +4057,7 @@ def test_axis_methods_nomask(self):
|
|
|
|
class TestMaskedArrayMathMethodsComplex:
|
|
# Test class for miscellaneous MaskedArrays methods.
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
# Base data definition.
|
|
x = np.array([8.375j, 7.545j, 8.828j, 8.5j, 1.757j, 5.928,
|
|
8.43, 7.78, 9.865, 5.878, 8.979, 4.732,
|
|
@@ -4111,7 +4111,7 @@ def test_varstd(self):
|
|
class TestMaskedArrayFunctions:
|
|
# Test class for miscellaneous functions.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
|
|
y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
|
|
m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
|
|
@@ -4749,7 +4749,7 @@ def test_convolve(self):
|
|
|
|
class TestMaskedFields:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
ilist = [1, 2, 3, 4, 5]
|
|
flist = [1.1, 2.2, 3.3, 4.4, 5.5]
|
|
slist = ['one', 'two', 'three', 'four', 'five']
|
|
@@ -4959,7 +4959,7 @@ def test_nested_ma(self):
|
|
|
|
class TestMaskedView:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
iterator = list(zip(np.arange(10), np.random.rand(10)))
|
|
data = np.array(iterator)
|
|
a = array(iterator, dtype=[('a', float), ('b', float)])
|
|
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
|
|
index 04bf8cfc2..3c95e25ea 100644
|
|
--- a/numpy/ma/tests/test_extras.py
|
|
+++ b/numpy/ma/tests/test_extras.py
|
|
@@ -1163,7 +1163,7 @@ def test_object(self):
|
|
|
|
class TestCov:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.data = array(np.random.rand(12))
|
|
|
|
def test_1d_without_missing(self):
|
|
@@ -1230,7 +1230,7 @@ def test_2d_with_missing(self):
|
|
|
|
class TestCorrcoef:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.data = array(np.random.rand(12))
|
|
self.data2 = array(np.random.rand(12))
|
|
|
|
diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py
|
|
index 4b2c01df9..77123c3cd 100644
|
|
--- a/numpy/ma/tests/test_mrecords.py
|
|
+++ b/numpy/ma/tests/test_mrecords.py
|
|
@@ -348,7 +348,7 @@ def test_exotic_formats(self):
|
|
|
|
class TestView:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
(a, b) = (np.arange(10), np.random.rand(10))
|
|
ndtype = [('a', float), ('b', float)]
|
|
arr = np.array(list(zip(a, b)), dtype=ndtype)
|
|
diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py
|
|
index 2b3034f9c..caf57746c 100644
|
|
--- a/numpy/ma/tests/test_old_ma.py
|
|
+++ b/numpy/ma/tests/test_old_ma.py
|
|
@@ -1,5 +1,7 @@
|
|
from functools import reduce
|
|
|
|
+import pytest
|
|
+
|
|
import numpy as np
|
|
import numpy.core.umath as umath
|
|
import numpy.core.fromnumeric as fromnumeric
|
|
@@ -33,7 +35,7 @@ def eq(v, w, msg=''):
|
|
|
|
class TestMa:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
|
|
y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
|
|
a10 = 10.
|
|
@@ -62,28 +64,26 @@ def test_testBasic1d(self):
|
|
assert_(eq(filled(xm, 1.e20), xf))
|
|
assert_(eq(x, xm))
|
|
|
|
- def test_testBasic2d(self):
|
|
+ @pytest.mark.parametrize("s", [(4, 3), (6, 2)])
|
|
+ def test_testBasic2d(self, s):
|
|
# Test of basic array creation and properties in 2 dimensions.
|
|
- for s in [(4, 3), (6, 2)]:
|
|
- (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
|
|
- x.shape = s
|
|
- y.shape = s
|
|
- xm.shape = s
|
|
- ym.shape = s
|
|
- xf.shape = s
|
|
-
|
|
- assert_(not isMaskedArray(x))
|
|
- assert_(isMaskedArray(xm))
|
|
- assert_equal(shape(xm), s)
|
|
- assert_equal(xm.shape, s)
|
|
- assert_equal(xm.size, reduce(lambda x, y:x * y, s))
|
|
- assert_equal(count(xm),
|
|
- len(m1) - reduce(lambda x, y:x + y, m1))
|
|
- assert_(eq(xm, xf))
|
|
- assert_(eq(filled(xm, 1.e20), xf))
|
|
- assert_(eq(x, xm))
|
|
- self.setup()
|
|
+ (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
|
|
+ x.shape = s
|
|
+ y.shape = s
|
|
+ xm.shape = s
|
|
+ ym.shape = s
|
|
+ xf.shape = s
|
|
|
|
+ assert_(not isMaskedArray(x))
|
|
+ assert_(isMaskedArray(xm))
|
|
+ assert_equal(shape(xm), s)
|
|
+ assert_equal(xm.shape, s)
|
|
+ assert_equal(xm.size, reduce(lambda x, y: x * y, s))
|
|
+ assert_equal(count(xm), len(m1) - reduce(lambda x, y: x + y, m1))
|
|
+ assert_(eq(xm, xf))
|
|
+ assert_(eq(filled(xm, 1.e20), xf))
|
|
+ assert_(eq(x, xm))
|
|
+
|
|
def test_testArithmetic(self):
|
|
# Test of basic arithmetic.
|
|
(x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
|
|
@@ -715,7 +715,7 @@ def test_assignment_by_condition_2(self):
|
|
|
|
|
|
class TestUfuncs:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6),
|
|
array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),)
|
|
|
|
@@ -781,7 +781,7 @@ def test_nonzero(self):
|
|
|
|
class TestArrayMethods:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.array([8.375, 7.545, 8.828, 8.5, 1.757, 5.928,
|
|
8.43, 7.78, 9.865, 5.878, 8.979, 4.732,
|
|
3.012, 6.022, 5.095, 3.116, 5.238, 3.957,
|
|
diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py
|
|
index 3491cef7f..313ca4ba7 100644
|
|
--- a/numpy/ma/tests/test_subclassing.py
|
|
+++ b/numpy/ma/tests/test_subclassing.py
|
|
@@ -150,7 +150,7 @@ def __array_wrap__(self, obj, context=None):
|
|
class TestSubclassing:
|
|
# Test suite for masked subclasses of ndarray.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.arange(5, dtype='float')
|
|
mx = msubarray(x, mask=[0, 1, 0, 0, 0])
|
|
self.data = (x, mx)
|
|
diff --git a/numpy/matrixlib/tests/test_masked_matrix.py b/numpy/matrixlib/tests/test_masked_matrix.py
|
|
index 95d3f44b6..d0ce357ae 100644
|
|
--- a/numpy/matrixlib/tests/test_masked_matrix.py
|
|
+++ b/numpy/matrixlib/tests/test_masked_matrix.py
|
|
@@ -173,7 +173,7 @@ def test_view(self):
|
|
class TestSubclassing:
|
|
# Test suite for masked subclasses of ndarray.
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
x = np.arange(5, dtype='float')
|
|
mx = MMatrix(x, mask=[0, 1, 0, 0, 0])
|
|
self.data = (x, mx)
|
|
diff --git a/numpy/random/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py
|
|
index 3ccb9103c..b550cd508 100644
|
|
--- a/numpy/random/tests/test_generator_mt19937.py
|
|
+++ b/numpy/random/tests/test_generator_mt19937.py
|
|
@@ -147,7 +147,7 @@ def test_multinomial_pvals_float32(self):
|
|
|
|
class TestMultivariateHypergeometric:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 8675309
|
|
|
|
def test_argument_validation(self):
|
|
@@ -280,7 +280,7 @@ def test_repeatability3(self):
|
|
|
|
|
|
class TestSetState:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
self.rg = Generator(MT19937(self.seed))
|
|
self.bit_generator = self.rg.bit_generator
|
|
@@ -707,7 +707,7 @@ class TestRandomDist:
|
|
# Make sure the random distribution returns the correct value for a
|
|
# given seed
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
|
|
def test_integers(self):
|
|
@@ -1823,7 +1823,7 @@ def test_zipf(self):
|
|
class TestBroadcast:
|
|
# tests that functions that broadcast behave
|
|
# correctly when presented with non-scalar arguments
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 123456789
|
|
|
|
|
|
@@ -2436,7 +2436,7 @@ def test_empty_outputs(self):
|
|
|
|
class TestThread:
|
|
# make sure each state produces the same sequence even in threads
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seeds = range(4)
|
|
|
|
def check_function(self, function, sz):
|
|
@@ -2482,7 +2482,7 @@ def gen_random(state, out):
|
|
|
|
# See Issue #4263
|
|
class TestSingleEltArrayInput:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.argOne = np.array([2])
|
|
self.argTwo = np.array([3])
|
|
self.argThree = np.array([4])
|
|
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
|
|
index 773b63653..f09141581 100644
|
|
--- a/numpy/random/tests/test_random.py
|
|
+++ b/numpy/random/tests/test_random.py
|
|
@@ -101,7 +101,7 @@ def test_multidimensional_pvals(self):
|
|
|
|
|
|
class TestSetState:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
self.prng = random.RandomState(self.seed)
|
|
self.state = self.prng.get_state()
|
|
@@ -290,7 +290,7 @@ class TestRandomDist:
|
|
# Make sure the random distribution returns the correct value for a
|
|
# given seed
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
|
|
def test_rand(self):
|
|
@@ -1048,7 +1048,7 @@ def test_zipf(self):
|
|
class TestBroadcast:
|
|
# tests that functions that broadcast behave
|
|
# correctly when presented with non-scalar arguments
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 123456789
|
|
|
|
def setSeed(self):
|
|
@@ -1617,7 +1617,7 @@ def test_logseries(self):
|
|
|
|
class TestThread:
|
|
# make sure each state produces the same sequence even in threads
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seeds = range(4)
|
|
|
|
def check_function(self, function, sz):
|
|
@@ -1660,7 +1660,7 @@ def gen_random(state, out):
|
|
|
|
# See Issue #4263
|
|
class TestSingleEltArrayInput:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.argOne = np.array([2])
|
|
self.argTwo = np.array([3])
|
|
self.argThree = np.array([4])
|
|
diff --git a/numpy/random/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py
|
|
index 861813a95..22b167224 100644
|
|
--- a/numpy/random/tests/test_randomstate.py
|
|
+++ b/numpy/random/tests/test_randomstate.py
|
|
@@ -177,7 +177,7 @@ def test_multinomial_pvals_float32(self):
|
|
|
|
|
|
class TestSetState:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
self.random_state = random.RandomState(self.seed)
|
|
self.state = self.random_state.get_state()
|
|
@@ -428,7 +428,7 @@ class TestRandomDist:
|
|
# Make sure the random distribution returns the correct value for a
|
|
# given seed
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 1234567890
|
|
|
|
def test_rand(self):
|
|
@@ -1293,7 +1293,7 @@ def test_zipf(self):
|
|
class TestBroadcast:
|
|
# tests that functions that broadcast behave
|
|
# correctly when presented with non-scalar arguments
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seed = 123456789
|
|
|
|
def set_seed(self):
|
|
@@ -1879,7 +1879,7 @@ def test_logseries(self):
|
|
|
|
class TestThread:
|
|
# make sure each state produces the same sequence even in threads
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.seeds = range(4)
|
|
|
|
def check_function(self, function, sz):
|
|
@@ -1925,7 +1925,7 @@ def gen_random(state, out):
|
|
|
|
# See Issue #4263
|
|
class TestSingleEltArrayInput:
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self.argOne = np.array([2])
|
|
self.argTwo = np.array([3])
|
|
self.argThree = np.array([4])
|
|
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
|
|
index 49eeecc8e..30c1a257d 100644
|
|
--- a/numpy/testing/tests/test_utils.py
|
|
+++ b/numpy/testing/tests/test_utils.py
|
|
@@ -65,7 +65,7 @@ def test_array_likes(self):
|
|
|
|
class TestArrayEqual(_GenericTest):
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_array_equal
|
|
|
|
def test_generic_rank1(self):
|
|
@@ -262,7 +262,7 @@ def test_build_err_msg_custom_precision(self):
|
|
|
|
class TestEqual(TestArrayEqual):
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_equal
|
|
|
|
def test_nan_items(self):
|
|
@@ -357,7 +357,7 @@ def test_object(self):
|
|
|
|
class TestArrayAlmostEqual(_GenericTest):
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_array_almost_equal
|
|
|
|
def test_closeness(self):
|
|
@@ -455,7 +455,7 @@ def all(self, *args, **kwargs):
|
|
|
|
class TestAlmostEqual(_GenericTest):
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_almost_equal
|
|
|
|
def test_closeness(self):
|
|
@@ -606,7 +606,7 @@ def all(self, *args, **kwargs):
|
|
|
|
class TestApproxEqual:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_approx_equal
|
|
|
|
def test_simple_0d_arrays(self):
|
|
@@ -649,7 +649,7 @@ def test_nan_items(self):
|
|
|
|
class TestArrayAssertLess:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
self._assert_func = assert_array_less
|
|
|
|
def test_simple_arrays(self):
|
|
@@ -759,7 +759,7 @@ def test_inf_compare_array(self):
|
|
@pytest.mark.skip(reason="The raises decorator depends on Nose")
|
|
class TestRaises:
|
|
|
|
- def setup(self):
|
|
+ def setup_method(self):
|
|
class MyException(Exception):
|
|
pass
|
|
|
|
--
|
|
2.17.1
|
|
|
|
|
|
From c77c08f44f6ccfbcb51b7d6b6b92ed0173eac835 Mon Sep 17 00:00:00 2001
|
|
From: Osama Esmail <osamaesmail@microsoft.com>
|
|
Date: Tue, 15 Nov 2022 11:25:47 -0800
|
|
Subject: [PATCH 2/2] missed on setup->setup_method
|
|
|
|
---
|
|
numpy/lib/tests/test_recfunctions.py | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py
|
|
index 3746de656..0e022d82f 100644
|
|
--- a/numpy/lib/tests/test_recfunctions.py
|
|
+++ b/numpy/lib/tests/test_recfunctions.py
|
|
@@ -893,7 +893,7 @@ def test_padded_dtype(self):
|
|
|
|
class TestJoinBy2:
|
|
@classmethod
|
|
- def setup(cls):
|
|
+ def setup_method(cls):
|
|
cls.a = np.array(list(zip(np.arange(10), np.arange(50, 60),
|
|
np.arange(100, 110))),
|
|
dtype=[('a', int), ('b', int), ('c', int)])
|
|
--
|
|
2.17.1
|
|
|