summaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py
diff options
context:
space:
mode:
authorblackhao <13851610112@163.com>2025-08-22 02:51:50 -0500
committerblackhao <13851610112@163.com>2025-08-22 02:51:50 -0500
commit4aab4087dc97906d0b9890035401175cdaab32d4 (patch)
tree4e2e9d88a711ec5b1cfa02e8ac72a55183b99123 /.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py
parentafa8f50d1d21c721dabcb31ad244610946ab65a3 (diff)
2.0
Diffstat (limited to '.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py')
-rw-r--r--.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py b/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py
new file mode 100644
index 0000000..96d5ffc
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_modules.py
@@ -0,0 +1,83 @@
+import textwrap
+
+import pytest
+
+from numpy.testing import IS_PYPY
+
+from . import util
+
+
+@pytest.mark.slow
+class TestModuleFilterPublicEntities(util.F2PyTest):
+ sources = [
+ util.getpath(
+ "tests", "src", "modules", "gh26920",
+ "two_mods_with_one_public_routine.f90"
+ )
+ ]
+ # we filter the only public function mod2
+ only = ["mod1_func1", ]
+
+ def test_gh26920(self):
+ # if it compiles and can be loaded, things are fine
+ pass
+
+
+@pytest.mark.slow
+class TestModuleWithoutPublicEntities(util.F2PyTest):
+ sources = [
+ util.getpath(
+ "tests", "src", "modules", "gh26920",
+ "two_mods_with_no_public_entities.f90"
+ )
+ ]
+ only = ["mod1_func1", ]
+
+ def test_gh26920(self):
+ # if it compiles and can be loaded, things are fine
+ pass
+
+
+@pytest.mark.slow
+class TestModuleDocString(util.F2PyTest):
+ sources = [util.getpath("tests", "src", "modules", "module_data_docstring.f90")]
+
+ @pytest.mark.xfail(IS_PYPY, reason="PyPy cannot modify tp_doc after PyType_Ready")
+ def test_module_docstring(self):
+ assert self.module.mod.__doc__ == textwrap.dedent(
+ """\
+ i : 'i'-scalar
+ x : 'i'-array(4)
+ a : 'f'-array(2,3)
+ b : 'f'-array(-1,-1), not allocated\x00
+ foo()\n
+ Wrapper for ``foo``.\n\n"""
+ )
+
+
+@pytest.mark.slow
+class TestModuleAndSubroutine(util.F2PyTest):
+ module_name = "example"
+ sources = [
+ util.getpath("tests", "src", "modules", "gh25337", "data.f90"),
+ util.getpath("tests", "src", "modules", "gh25337", "use_data.f90"),
+ ]
+
+ def test_gh25337(self):
+ self.module.data.set_shift(3)
+ assert "data" in dir(self.module)
+
+
+@pytest.mark.slow
+class TestUsedModule(util.F2PyTest):
+ module_name = "fmath"
+ sources = [
+ util.getpath("tests", "src", "modules", "use_modules.f90"),
+ ]
+
+ def test_gh25867(self):
+ compiled_mods = [x for x in dir(self.module) if "__" not in x]
+ assert "useops" in compiled_mods
+ assert self.module.useops.sum_and_double(3, 7) == 20
+ assert "mathops" in compiled_mods
+ assert self.module.mathops.add(3, 7) == 10