diff options
author | Rohit Goswami <rog32@hi.is> | 2021-12-04 19:33:43 +0000 |
---|---|---|
committer | Rohit Goswami <rog32@hi.is> | 2021-12-06 00:13:01 +0000 |
commit | 8c588512d69574e4b6bfe0d21f1922a70ec56812 (patch) | |
tree | c7ac031335da8f5b32140d05c7093f93d206f511 /numpy/f2py/tests/test_abstract_interface.py | |
parent | d14d2c359fcbd499b73d254f0c20dd1a884ff9a3 (diff) | |
download | numpy-8c588512d69574e4b6bfe0d21f1922a70ec56812.tar.gz |
MAINT,TST: Refactor F2PY tests
Diffstat (limited to 'numpy/f2py/tests/test_abstract_interface.py')
-rw-r--r-- | numpy/f2py/tests/test_abstract_interface.py | 59 |
1 files changed, 8 insertions, 51 deletions
diff --git a/numpy/f2py/tests/test_abstract_interface.py b/numpy/f2py/tests/test_abstract_interface.py index 7aecf57fc..88fd8854f 100644 --- a/numpy/f2py/tests/test_abstract_interface.py +++ b/numpy/f2py/tests/test_abstract_interface.py @@ -3,65 +3,22 @@ import textwrap from . import util from numpy.f2py import crackfortran +from numpy.testing import assert_ + class TestAbstractInterface(util.F2PyTest): - suffix = ".f90" + sources = [util.getpath("tests", "src", "abstract_interface", "foo.f90")] skip = ["add1", "add2"] - code = textwrap.dedent(""" - module ops_module - - abstract interface - subroutine op(x, y, z) - integer, intent(in) :: x, y - integer, intent(out) :: z - end subroutine - end interface - - contains - - subroutine foo(x, y, r1, r2) - integer, intent(in) :: x, y - integer, intent(out) :: r1, r2 - procedure (op) add1, add2 - procedure (op), pointer::p - p=>add1 - call p(x, y, r1) - p=>add2 - call p(x, y, r2) - end subroutine - end module - - subroutine add1(x, y, z) - integer, intent(in) :: x, y - integer, intent(out) :: z - z = x + y - end subroutine - - subroutine add2(x, y, z) - integer, intent(in) :: x, y - integer, intent(out) :: z - z = x + 2 * y - end subroutine - """) - def test_abstract_interface(self): - assert self.module.ops_module.foo(3, 5) == (8, 13) + assert_(self.module.ops_module.foo(3, 5) == (8, 13)) - def test_parse_abstract_interface(self, tmp_path): + def test_parse_abstract_interface(self): # Test gh18403 - f_path = Path(tmp_path / "gh18403_mod.f90") - f_path.write_text( - textwrap.dedent("""\ - module test - abstract interface - subroutine foo() - end subroutine - end interface - end module test - """)) - mod = crackfortran.crackfortran([str(f_path)]) + fpath = util.getpath("tests", "src", "abstract_interface", + "gh18403_mod.f90") + mod = crackfortran.crackfortran([str(fpath)]) assert len(mod) == 1 assert len(mod[0]["body"]) == 1 assert mod[0]["body"][0]["block"] == "abstract interface" |