Skip to content

Commit

Permalink
MAINT: Refactor tests a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoZeke committed Feb 25, 2024
1 parent a60de40 commit d18c703
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 40 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ numpy/version.py linguist-generated
# F2py
./doc/source/f2py/*.pyf text
./doc/source/f2py/*.dat text
./numpy/f2py/tests/src/module_data/mod.mod binary

# Documents
*.md text diff=markdown
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GTAGS
*.o.d
*.py[ocd]
*.so
*.mod

# Packages #
############
Expand Down
Binary file removed numpy/f2py/tests/src/module_data/mod.mod
Binary file not shown.
28 changes: 0 additions & 28 deletions numpy/f2py/tests/test_module_doc.py

This file was deleted.

35 changes: 35 additions & 0 deletions numpy/f2py/tests/test_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
import textwrap

from . import util
from numpy.testing import IS_PYPY


@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)
11 changes: 0 additions & 11 deletions numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@ def test_include_path():
assert fname in fnames_in_dir


class TestModuleAndSubroutine(util.F2PyTest):
module_name = "example"
sources = [util.getpath("tests", "src", "regression", "gh25337", "data.f90"),
util.getpath("tests", "src", "regression", "gh25337", "use_data.f90")]

@pytest.mark.slow
def test_gh25337(self):
self.module.data.set_shift(3)
assert "data" in dir(self.module)


class TestIncludeFiles(util.F2PyTest):
sources = [util.getpath("tests", "src", "regression", "incfile.f90")]
options = [f"-I{util.getpath('tests', 'src', 'regression')}",
Expand Down

0 comments on commit d18c703

Please sign in to comment.