Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b72339f

Browse files
committed
MAINT: Add check to pass tests [f2py]
1 parent af43752 commit b72339f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

numpy/f2py/f2py2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def run_compile():
619619
for s in flib_flags:
620620
v = '--fcompiler='
621621
if s[:len(v)] == v:
622-
if sys.version_info >= (3, 12):
622+
if MESON_ONLY_VER or backend_key == 'meson':
623623
outmess(
624624
"--fcompiler cannot be used with meson,"
625625
"set compiler with the FC environment variable\n"

numpy/f2py/tests/test_f2py2e.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_gen_pyf_no_overwrite(capfd, hello_world_f90, monkeypatch):
198198
assert "Use --overwrite-signature to overwrite" in err
199199

200200

201-
@pytest.mark.skipif((platform.system() != 'Linux') or (sys.version_info <= (3, 12)),
201+
@pytest.mark.skipif((platform.system() != 'Linux') and (sys.version_info <= (3, 12)),
202202
reason='Compiler and 3.12 required')
203203
def test_untitled_cli(capfd, hello_world_f90, monkeypatch):
204204
"""Check that modules are named correctly
@@ -213,7 +213,7 @@ def test_untitled_cli(capfd, hello_world_f90, monkeypatch):
213213
assert "untitledmodule.c" in out
214214

215215

216-
@pytest.mark.skipif(platform.system() != 'Linux', reason='Compiler required')
216+
@pytest.mark.skipif((platform.system() != 'Linux') and (sys.version_info <= (3, 12)), reason='Compiler and 3.12 required')
217217
def test_no_py312_distutils_fcompiler(capfd, hello_world_f90, monkeypatch):
218218
"""Check that no distutils imports are performed on 3.12
219219
CLI :: --fcompiler --help-link --backend distutils
@@ -222,7 +222,7 @@ def test_no_py312_distutils_fcompiler(capfd, hello_world_f90, monkeypatch):
222222
foutl = get_io_paths(hello_world_f90, mname=MNAME)
223223
ipath = foutl.f90inp
224224
monkeypatch.setattr(
225-
sys, "argv", f"f2py {ipath} --backend meson -c --fcompiler=gfortran -m {MNAME}".split()
225+
sys, "argv", f"f2py {ipath} -c --fcompiler=gfortran -m {MNAME}".split()
226226
)
227227
with util.switchdir(ipath.parent):
228228
f2pycli()
@@ -235,15 +235,14 @@ def test_no_py312_distutils_fcompiler(capfd, hello_world_f90, monkeypatch):
235235
f2pycli()
236236
out, _ = capfd.readouterr()
237237
assert "Use --dep for meson builds" in out
238-
if (sys.version_info >= (3, 12)):
239-
MNAME = "hi2" # Needs to be different for a new -c
240-
monkeypatch.setattr(
241-
sys, "argv", f"f2py {ipath} -c -m {MNAME} --backend distutils".split()
242-
)
243-
with util.switchdir(ipath.parent):
244-
f2pycli()
245-
out, _ = capfd.readouterr()
246-
assert "Cannot use distutils backend with Python>=3.12" in out
238+
MNAME = "hi2" # Needs to be different for a new -c
239+
monkeypatch.setattr(
240+
sys, "argv", f"f2py {ipath} -c -m {MNAME} --backend distutils".split()
241+
)
242+
with util.switchdir(ipath.parent):
243+
f2pycli()
244+
out, _ = capfd.readouterr()
245+
assert "Cannot use distutils backend with Python>=3.12" in out
247246

248247

249248
@pytest.mark.xfail

0 commit comments

Comments
 (0)