summaryrefslogtreecommitdiff
path: root/numpy/f2py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-03-25 12:34:16 -0600
committerCharles Harris <charlesr.harris@gmail.com>2018-04-04 06:36:36 -0600
commit7e5a41de9fab731e27a761c01302a0a93e2d1070 (patch)
treedbd6265800ad401476bcde904e9bba86f6af2b85 /numpy/f2py
parent359e53ef8e479eefac0e184d4d25af50c2779ce0 (diff)
downloadnumpy-7e5a41de9fab731e27a761c01302a0a93e2d1070.tar.gz
TST: Switch to using pytest markers
Use standard pytest markers everywhere in the numpy tests. At this point there should be no nose dependency. However, nose is required to test the legacy decorators if so desired. At this point, numpy test cannot be run in the way with runtests, rather installed numpy can be tested with `pytest --pyargs numpy` as long as that is not run from the repo. Run it from the tools directory or some such.
Diffstat (limited to 'numpy/f2py')
-rw-r--r--numpy/f2py/tests/test_assumed_shape.py5
-rw-r--r--numpy/f2py/tests/test_block_docstring.py8
-rw-r--r--numpy/f2py/tests/test_callback.py15
-rw-r--r--numpy/f2py/tests/test_common.py7
-rw-r--r--numpy/f2py/tests/test_kind.py5
-rw-r--r--numpy/f2py/tests/test_mixed.py7
-rw-r--r--numpy/f2py/tests/test_parameter.py21
-rw-r--r--numpy/f2py/tests/test_quoted_character.py13
-rw-r--r--numpy/f2py/tests/test_regression.py5
-rw-r--r--numpy/f2py/tests/test_return_character.py8
-rw-r--r--numpy/f2py/tests/test_return_complex.py8
-rw-r--r--numpy/f2py/tests/test_return_integer.py8
-rw-r--r--numpy/f2py/tests/test_return_logical.py8
-rw-r--r--numpy/f2py/tests/test_return_real.py10
-rw-r--r--numpy/f2py/tests/test_size.py9
-rw-r--r--numpy/f2py/tests/test_string.py5
-rw-r--r--numpy/f2py/tests/util.py7
17 files changed, 88 insertions, 61 deletions
diff --git a/numpy/f2py/tests/test_assumed_shape.py b/numpy/f2py/tests/test_assumed_shape.py
index 371aab755..b6fde20e4 100644
--- a/numpy/f2py/tests/test_assumed_shape.py
+++ b/numpy/f2py/tests/test_assumed_shape.py
@@ -1,8 +1,9 @@
from __future__ import division, absolute_import, print_function
import os
+import pytest
-from numpy.testing import run_module_suite, assert_, dec
+from numpy.testing import run_module_suite, assert_
from . import util
@@ -17,7 +18,7 @@ class TestAssumedShapeSumExample(util.F2PyTest):
_path('src', 'assumed_shape', 'foo_mod.f90'),
]
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
r = self.module.fsum([1, 2])
assert_(r == 3, repr(r))
diff --git a/numpy/f2py/tests/test_block_docstring.py b/numpy/f2py/tests/test_block_docstring.py
index eb11201ef..c820895c5 100644
--- a/numpy/f2py/tests/test_block_docstring.py
+++ b/numpy/f2py/tests/test_block_docstring.py
@@ -2,21 +2,23 @@ from __future__ import division, absolute_import, print_function
import textwrap
import sys
+import pytest
from . import util
-from numpy.testing import run_module_suite, assert_equal, dec
+from numpy.testing import run_module_suite, assert_equal
class TestBlockDocString(util.F2PyTest):
code = """
SUBROUTINE FOO()
INTEGER BAR(2, 3)
-
+
COMMON /BLOCK/ BAR
RETURN
END
"""
- @dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @pytest.mark.skipif(sys.platform=='win32',
+ reason='Fails with MinGW64 Gfortran (Issue #9673)')
def test_block_docstring(self):
expected = "'i'-array(2,3)\n"
assert_equal(self.module.block.__doc__, expected)
diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py
index 1b9a582ed..19aa4dd6e 100644
--- a/numpy/f2py/tests/test_callback.py
+++ b/numpy/f2py/tests/test_callback.py
@@ -3,9 +3,10 @@ from __future__ import division, absolute_import, print_function
import math
import textwrap
import sys
+import pytest
import numpy as np
-from numpy.testing import run_module_suite, assert_, assert_equal, dec
+from numpy.testing import run_module_suite, assert_, assert_equal
from . import util
@@ -60,12 +61,12 @@ cf2py intent(out) a
end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t,t2".split(","):
self.check_function(name)
- @dec.slow
+ @pytest.mark.slow
def test_docstring(self):
expected = """
a = t(fun,[fun_extra_args])
@@ -130,8 +131,8 @@ cf2py intent(out) a
r = t(a.mth)
assert_(r == 9, repr(r))
- @dec.knownfailureif(sys.platform=='win32',
- msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @pytest.mark.skipif(sys.platform=='win32',
+ reason='Fails with MinGW64 Gfortran (Issue #9673)')
def test_string_callback(self):
def callback(code):
@@ -144,8 +145,8 @@ cf2py intent(out) a
r = f(callback)
assert_(r == 0, repr(r))
- @dec.knownfailureif(sys.platform=='win32',
- msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @pytest.mark.skipif(sys.platform=='win32',
+ reason='Fails with MinGW64 Gfortran (Issue #9673)')
def test_string_callback_array(self):
# See gh-10027
cu = np.zeros((1, 8), 'S1')
diff --git a/numpy/f2py/tests/test_common.py b/numpy/f2py/tests/test_common.py
index 81082e575..30640f8e9 100644
--- a/numpy/f2py/tests/test_common.py
+++ b/numpy/f2py/tests/test_common.py
@@ -2,10 +2,12 @@ from __future__ import division, absolute_import, print_function
import os
import sys
+import pytest
+
import numpy as np
from . import util
-from numpy.testing import run_module_suite, assert_array_equal, dec
+from numpy.testing import run_module_suite, assert_array_equal
def _path(*a):
return os.path.join(*((os.path.dirname(__file__),) + a))
@@ -13,7 +15,8 @@ def _path(*a):
class TestCommonBlock(util.F2PyTest):
sources = [_path('src', 'common', 'block.f')]
- @dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @pytest.mark.skipif(sys.platform=='win32',
+ reason='Fails with MinGW64 Gfortran (Issue #9673)')
def test_common_block(self):
self.module.initcb()
assert_array_equal(self.module.block.long_bn,
diff --git a/numpy/f2py/tests/test_kind.py b/numpy/f2py/tests/test_kind.py
index 7cfe2e977..61c39a092 100644
--- a/numpy/f2py/tests/test_kind.py
+++ b/numpy/f2py/tests/test_kind.py
@@ -1,8 +1,9 @@
from __future__ import division, absolute_import, print_function
import os
+import pytest
-from numpy.testing import run_module_suite, assert_, dec
+from numpy.testing import run_module_suite, assert_
from numpy.f2py.crackfortran import (
_selected_int_kind_func as selected_int_kind,
_selected_real_kind_func as selected_real_kind
@@ -17,7 +18,7 @@ def _path(*a):
class TestKind(util.F2PyTest):
sources = [_path('src', 'kind', 'foo.f90')]
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
selectedrealkind = self.module.selectedrealkind
selectedintkind = self.module.selectedintkind
diff --git a/numpy/f2py/tests/test_mixed.py b/numpy/f2py/tests/test_mixed.py
index c145a4b23..e6eea8c4f 100644
--- a/numpy/f2py/tests/test_mixed.py
+++ b/numpy/f2py/tests/test_mixed.py
@@ -2,8 +2,9 @@ from __future__ import division, absolute_import, print_function
import os
import textwrap
+import pytest
-from numpy.testing import run_module_suite, assert_, assert_equal, dec
+from numpy.testing import run_module_suite, assert_, assert_equal
from . import util
@@ -16,13 +17,13 @@ class TestMixed(util.F2PyTest):
_path('src', 'mixed', 'foo_fixed.f90'),
_path('src', 'mixed', 'foo_free.f90')]
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
assert_(self.module.bar11() == 11)
assert_(self.module.foo_fixed.bar12() == 12)
assert_(self.module.foo_free.bar13() == 13)
- @dec.slow
+ @pytest.mark.slow
def test_docstring(self):
expected = """
a = bar11()
diff --git a/numpy/f2py/tests/test_parameter.py b/numpy/f2py/tests/test_parameter.py
index 285b693a1..11132475e 100644
--- a/numpy/f2py/tests/test_parameter.py
+++ b/numpy/f2py/tests/test_parameter.py
@@ -2,9 +2,10 @@ from __future__ import division, absolute_import, print_function
import os
import math
+import pytest
import numpy as np
-from numpy.testing import run_module_suite, dec, assert_raises, assert_equal
+from numpy.testing import run_module_suite, assert_raises, assert_equal
from . import util
@@ -22,7 +23,7 @@ class TestParameters(util.F2PyTest):
_path('src', 'parameter', 'constant_non_compound.f90'),
]
- @dec.slow
+ @pytest.mark.slow
def test_constant_real_single(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float32)[::2]
@@ -33,7 +34,7 @@ class TestParameters(util.F2PyTest):
self.module.foo_single(x)
assert_equal(x, [0 + 1 + 2*3, 1, 2])
- @dec.slow
+ @pytest.mark.slow
def test_constant_real_double(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float64)[::2]
@@ -44,7 +45,7 @@ class TestParameters(util.F2PyTest):
self.module.foo_double(x)
assert_equal(x, [0 + 1 + 2*3, 1, 2])
- @dec.slow
+ @pytest.mark.slow
def test_constant_compound_int(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.int32)[::2]
@@ -55,14 +56,14 @@ class TestParameters(util.F2PyTest):
self.module.foo_compound_int(x)
assert_equal(x, [0 + 1 + 2*6, 1, 2])
- @dec.slow
+ @pytest.mark.slow
def test_constant_non_compound_int(self):
# check values
x = np.arange(4, dtype=np.int32)
self.module.foo_non_compound_int(x)
assert_equal(x, [0 + 1 + 2 + 3*4, 1, 2, 3])
- @dec.slow
+ @pytest.mark.slow
def test_constant_integer_int(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.int32)[::2]
@@ -73,7 +74,7 @@ class TestParameters(util.F2PyTest):
self.module.foo_int(x)
assert_equal(x, [0 + 1 + 2*3, 1, 2])
- @dec.slow
+ @pytest.mark.slow
def test_constant_integer_long(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.int64)[::2]
@@ -84,7 +85,7 @@ class TestParameters(util.F2PyTest):
self.module.foo_long(x)
assert_equal(x, [0 + 1 + 2*3, 1, 2])
- @dec.slow
+ @pytest.mark.slow
def test_constant_both(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float64)[::2]
@@ -95,7 +96,7 @@ class TestParameters(util.F2PyTest):
self.module.foo(x)
assert_equal(x, [0 + 1*3*3 + 2*3*3, 1*3, 2*3])
- @dec.slow
+ @pytest.mark.slow
def test_constant_no(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float64)[::2]
@@ -106,7 +107,7 @@ class TestParameters(util.F2PyTest):
self.module.foo_no(x)
assert_equal(x, [0 + 1*3*3 + 2*3*3, 1*3, 2*3])
- @dec.slow
+ @pytest.mark.slow
def test_constant_sum(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float64)[::2]
diff --git a/numpy/f2py/tests/test_quoted_character.py b/numpy/f2py/tests/test_quoted_character.py
index 4770c11c4..748a17a38 100644
--- a/numpy/f2py/tests/test_quoted_character.py
+++ b/numpy/f2py/tests/test_quoted_character.py
@@ -1,16 +1,16 @@
from __future__ import division, absolute_import, print_function
-from . import util
-
-from numpy.testing import run_module_suite, assert_equal, dec
-
import sys
+import pytest
+
+from numpy.testing import run_module_suite, assert_equal
+from . import util
class TestQuotedCharacter(util.F2PyTest):
code = """
SUBROUTINE FOO(OUT1, OUT2, OUT3, OUT4, OUT5, OUT6)
CHARACTER SINGLE, DOUBLE, SEMICOL, EXCLA, OPENPAR, CLOSEPAR
- PARAMETER (SINGLE="'", DOUBLE='"', SEMICOL=';', EXCLA="!",
+ PARAMETER (SINGLE="'", DOUBLE='"', SEMICOL=';', EXCLA="!",
1 OPENPAR="(", CLOSEPAR=")")
CHARACTER OUT1, OUT2, OUT3, OUT4, OUT5, OUT6
Cf2py intent(out) OUT1, OUT2, OUT3, OUT4, OUT5, OUT6
@@ -24,7 +24,8 @@ Cf2py intent(out) OUT1, OUT2, OUT3, OUT4, OUT5, OUT6
END
"""
- @dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran (Issue #9673)')
+ @pytest.mark.skipif(sys.platform=='win32',
+ reason='Fails with MinGW64 Gfortran (Issue #9673)')
def test_quoted_character(self):
assert_equal(self.module.foo(), (b"'", b'"', b';', b'!', b'(', b')'))
diff --git a/numpy/f2py/tests/test_regression.py b/numpy/f2py/tests/test_regression.py
index c34a5781c..a70d2c93f 100644
--- a/numpy/f2py/tests/test_regression.py
+++ b/numpy/f2py/tests/test_regression.py
@@ -2,9 +2,10 @@ from __future__ import division, absolute_import, print_function
import os
import math
+import pytest
import numpy as np
-from numpy.testing import run_module_suite, dec, assert_raises, assert_equal
+from numpy.testing import run_module_suite, assert_raises, assert_equal
from . import util
@@ -17,7 +18,7 @@ class TestIntentInOut(util.F2PyTest):
# Check that intent(in out) translates as intent(inout)
sources = [_path('src', 'regression', 'inout.f90')]
- @dec.slow
+ @pytest.mark.slow
def test_inout(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.float32)[::2]
diff --git a/numpy/f2py/tests/test_return_character.py b/numpy/f2py/tests/test_return_character.py
index 217b2c9dd..ec2d02658 100644
--- a/numpy/f2py/tests/test_return_character.py
+++ b/numpy/f2py/tests/test_return_character.py
@@ -1,7 +1,9 @@
from __future__ import division, absolute_import, print_function
+import pytest
+
from numpy import array
-from numpy.testing import run_module_suite, assert_, dec
+from numpy.testing import run_module_suite, assert_
from . import util
@@ -79,7 +81,7 @@ cf2py intent(out) ts
end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t5,s0,s1,s5,ss".split(","):
self.check_function(getattr(self.module, name))
@@ -138,7 +140,7 @@ module f90_return_char
end module f90_return_char
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t5,ts,s0,s1,s5,ss".split(","):
self.check_function(getattr(self.module.f90_return_char, name))
diff --git a/numpy/f2py/tests/test_return_complex.py b/numpy/f2py/tests/test_return_complex.py
index 73ced8ed8..72c00afeb 100644
--- a/numpy/f2py/tests/test_return_complex.py
+++ b/numpy/f2py/tests/test_return_complex.py
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function
+import pytest
+
from numpy import array
from numpy.compat import long
-from numpy.testing import run_module_suite, assert_, assert_raises, dec
+from numpy.testing import run_module_suite, assert_, assert_raises
from . import util
@@ -102,7 +104,7 @@ cf2py intent(out) td
end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t8,t16,td,s0,s8,s16,sd".split(","):
self.check_function(getattr(self.module, name))
@@ -161,7 +163,7 @@ module f90_return_complex
end module f90_return_complex
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t8,t16,td,s0,s8,s16,sd".split(","):
self.check_function(getattr(self.module.f90_return_complex, name))
diff --git a/numpy/f2py/tests/test_return_integer.py b/numpy/f2py/tests/test_return_integer.py
index df8fc7c97..befc515a2 100644
--- a/numpy/f2py/tests/test_return_integer.py
+++ b/numpy/f2py/tests/test_return_integer.py
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function
+import pytest
+
from numpy import array
from numpy.compat import long
-from numpy.testing import run_module_suite, assert_, assert_raises, dec
+from numpy.testing import run_module_suite, assert_, assert_raises
from . import util
@@ -101,7 +103,7 @@ cf2py intent(out) t8
end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
self.check_function(getattr(self.module, name))
@@ -171,7 +173,7 @@ module f90_return_integer
end module f90_return_integer
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
self.check_function(getattr(self.module.f90_return_integer, name))
diff --git a/numpy/f2py/tests/test_return_logical.py b/numpy/f2py/tests/test_return_logical.py
index 221dc3cbd..917cc3f60 100644
--- a/numpy/f2py/tests/test_return_logical.py
+++ b/numpy/f2py/tests/test_return_logical.py
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function
+import pytest
+
from numpy import array
from numpy.compat import long
-from numpy.testing import run_module_suite, assert_, assert_raises, dec
+from numpy.testing import run_module_suite, assert_, assert_raises
from . import util
@@ -110,7 +112,7 @@ c t8 = value
c end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t2,t4,s0,s1,s2,s4".split(","):
self.check_function(getattr(self.module, name))
@@ -180,7 +182,7 @@ module f90_return_logical
end module f90_return_logical
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
self.check_function(getattr(self.module.f90_return_logical, name))
diff --git a/numpy/f2py/tests/test_return_real.py b/numpy/f2py/tests/test_return_real.py
index a81549083..addbdcf49 100644
--- a/numpy/f2py/tests/test_return_real.py
+++ b/numpy/f2py/tests/test_return_real.py
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function
+import pytest
+
from numpy import array
from numpy.compat import long
-from numpy.testing import run_module_suite, assert_, assert_raises, dec
+from numpy.testing import run_module_suite, assert_, assert_raises
from . import util
@@ -82,7 +84,7 @@ end interface
end python module c_ext_return_real
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t4,t8,s4,s8".split(","):
self.check_function(getattr(self.module, name))
@@ -137,7 +139,7 @@ cf2py intent(out) td
end
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
self.check_function(getattr(self.module, name))
@@ -196,7 +198,7 @@ module f90_return_real
end module f90_return_real
"""
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
self.check_function(getattr(self.module.f90_return_real, name))
diff --git a/numpy/f2py/tests/test_size.py b/numpy/f2py/tests/test_size.py
index 1fcad05a5..59de9a64e 100644
--- a/numpy/f2py/tests/test_size.py
+++ b/numpy/f2py/tests/test_size.py
@@ -1,8 +1,9 @@
from __future__ import division, absolute_import, print_function
import os
+import pytest
-from numpy.testing import run_module_suite, assert_equal, dec
+from numpy.testing import run_module_suite, assert_equal
from . import util
@@ -13,7 +14,7 @@ def _path(*a):
class TestSizeSumExample(util.F2PyTest):
sources = [_path('src', 'size', 'foo.f90')]
- @dec.slow
+ @pytest.mark.slow
def test_all(self):
r = self.module.foo([[]])
assert_equal(r, [0], repr(r))
@@ -27,7 +28,7 @@ class TestSizeSumExample(util.F2PyTest):
r = self.module.foo([[1, 2], [3, 4], [5, 6]])
assert_equal(r, [3, 7, 11], repr(r))
- @dec.slow
+ @pytest.mark.slow
def test_transpose(self):
r = self.module.trans([[]])
assert_equal(r.T, [[]], repr(r))
@@ -38,7 +39,7 @@ class TestSizeSumExample(util.F2PyTest):
r = self.module.trans([[1, 2, 3], [4, 5, 6]])
assert_equal(r, [[1, 4], [2, 5], [3, 6]], repr(r))
- @dec.slow
+ @pytest.mark.slow
def test_flatten(self):
r = self.module.flatten([[]])
assert_equal(r, [], repr(r))
diff --git a/numpy/f2py/tests/test_string.py b/numpy/f2py/tests/test_string.py
index 065861c0b..79eeca1e9 100644
--- a/numpy/f2py/tests/test_string.py
+++ b/numpy/f2py/tests/test_string.py
@@ -1,8 +1,9 @@
from __future__ import division, absolute_import, print_function
import os
+import pytest
-from numpy.testing import run_module_suite, assert_array_equal, dec
+from numpy.testing import run_module_suite, assert_array_equal
import numpy as np
from . import util
@@ -13,7 +14,7 @@ def _path(*a):
class TestString(util.F2PyTest):
sources = [_path('src', 'string', 'char.f90')]
- @dec.slow
+ @pytest.mark.slow
def test_char(self):
strings = np.array(['ab', 'cd', 'ef'], dtype='c').T
inp, out = self.module.char_test.change_strings(strings, strings.shape[1])
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index 881b32810..466fd4970 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -16,10 +16,11 @@ import atexit
import textwrap
import re
import random
+import pytest
import numpy.f2py
from numpy.compat import asbytes, asstr
-from numpy.testing import SkipTest, temppath, dec
+from numpy.testing import SkipTest, temppath
from importlib import import_module
try:
@@ -319,8 +320,10 @@ class F2PyTest(object):
module = None
module_name = None
- @dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran (Issue #9673)')
def setup(self):
+ if sys.platform == 'win32':
+ raise SkipTest('Fails with MinGW64 Gfortran (Issue #9673)')
+
if self.module is not None:
return