summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorNamami Shanker <namami2011@gmail.com>2022-06-21 17:20:47 +0530
committerNamami Shanker <namami2011@gmail.com>2022-06-23 18:43:19 +0530
commit55b16bf711c7d1d1e7405320a0ead7d664c1278e (patch)
treef30f885b9bf8b1cf5a56a2376a81383857df4d00 /numpy
parentdf7ccc4034e04fd3fadaa33710c727589dc0d938 (diff)
downloadnumpy-55b16bf711c7d1d1e7405320a0ead7d664c1278e.tar.gz
TST: Add f2py2e f2cmap flag test
Diffstat (limited to 'numpy')
-rw-r--r--numpy/f2py/tests/test_f2py2e.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/numpy/f2py/tests/test_f2py2e.py b/numpy/f2py/tests/test_f2py2e.py
index 9de043d73..ef8e46688 100644
--- a/numpy/f2py/tests/test_f2py2e.py
+++ b/numpy/f2py/tests/test_f2py2e.py
@@ -79,6 +79,17 @@ def retreal_f77(tmpdir_factory):
fn.write_text(fdat, encoding="ascii")
return fn
+@pytest.fixture(scope="session")
+def f2cmap_f90(tmpdir_factory):
+ """Generates a single f90 file for testing"""
+ fdat = util.getpath("tests", "src", "f2cmap", "isoFortranEnvMap.f90").read_text()
+ f2cmap = util.getpath("tests", "src", "f2cmap", ".f2py_f2cmap").read_text()
+ fn = tmpdir_factory.getbasetemp() / "f2cmap.f90"
+ fmap = tmpdir_factory.getbasetemp() / "mapfile"
+ fn.write_text(fdat, encoding="ascii")
+ fmap.write_text(f2cmap, encoding="ascii")
+ return fn
+
def test_gen_pyf(capfd, hello_world_f90, monkeypatch):
"""Ensures that a signature file is generated via the CLI
@@ -533,13 +544,22 @@ def test_hlink():
pass
-def test_f2cmap():
+def test_f2cmap(capfd, f2cmap_f90, monkeypatch):
"""Check that Fortran-to-Python KIND specs can be passed
CLI :: --f2cmap
"""
- # TODO: populate
- pass
+ ipath = Path(f2cmap_f90)
+ monkeypatch.setattr(sys, "argv", f'f2py -m blah {ipath} --f2cmap mapfile'.split())
+
+ with util.switchdir(ipath.parent):
+ f2pycli()
+ out, _ = capfd.readouterr()
+ assert "Reading f2cmap from 'mapfile' ..." in out
+ assert "Mapping \"real(kind=real32)\" to \"float\"" in out
+ assert "Mapping \"real(kind=real64)\" to \"double\"" in out
+ assert "Mapping \"integer(kind=int64)\" to \"long_long\"" in out
+ assert "Successfully applied user defined f2cmap changes" in out
def test_quiet(capfd, hello_world_f90, monkeypatch):