Skip to content

Commit

Permalink
BUG: Fix testing of f2py.compile from strings.
Browse files Browse the repository at this point in the history
The test should not be run if there is no Fortran compiler. This PR
moves it to `numpy/f2py/tests/test_compile_function.py`, which is
appropriate for the test and a place where the presence of the needed
compilers is already checked for.
  • Loading branch information
charris committed Jan 20, 2019
1 parent 568d0f7 commit c9c154f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
17 changes: 17 additions & 0 deletions numpy/f2py/tests/test_compile_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,20 @@ def test_f2py_init_compile_bad_cmd():
assert_equal(ret_val, 127)
finally:
sys.executable = temp


@pytest.mark.parametrize('fsource',
['program test_f2py\nend program test_f2py',
b'program test_f2py\nend program test_f2py',])
def test_compile_from_strings(tmpdir, fsource):
# Make sure we can compile str and bytes gh-12796
cwd = os.getcwd()
try:
os.chdir(str(tmpdir))
ret_val = numpy.f2py.compile(
fsource,
modulename='test_compile_from_strings',
extension='.f90')
assert_equal(ret_val, 0)
finally:
os.chdir(cwd)
14 changes: 0 additions & 14 deletions numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,3 @@ def test_inout(self):
x = np.arange(3, dtype=np.float32)
self.module.foo(x)
assert_equal(x, [3, 1, 2])

@pytest.mark.parametrize('code', [
'program test_f2py\nend program test_f2py',
b'program test_f2py\nend program test_f2py',
])
def test_compile(tmpdir, code):
# Make sure we can compile str and bytes gh-12796
cwd = os.getcwd()
try:
os.chdir(str(tmpdir))
ret = np.f2py.compile(code, modulename='test1_f2py', extension='.f90')
assert_equal(ret, 0)
finally:
os.chdir(cwd)

0 comments on commit c9c154f

Please sign in to comment.