Skip to content

Commit 2673e1f

Browse files
committed
test(fortran): tests run only if should be
1 parent 674334e commit 2673e1f

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

test/test_dependencies.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ class Tests(unittest.TestCase):
99
def test_cython(self):
1010
import cython
1111

12-
def test_numpy(self):
13-
import numpy as np
14-
self.assertIsNotNone(np.zeros((10, 10), dtype=int))
15-
1612
@unittest.skip('not ready yet')
1713
def test_pyopencl(self):
1814
import pyopencl

test/test_fortran.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,27 @@
1010
import numpy as np
1111
import timing
1212

13-
from transpyle.general.code_reader import CodeReader
14-
from transpyle.general.binder import Binder
15-
from transpyle.fortran.parser import FortranParser
16-
from transpyle.fortran.ast_generalizer import FortranAstGeneralizer
17-
from transpyle.fortran.unparser import Fortran77Unparser
18-
from transpyle.fortran.compiler import F2PyCompiler
19-
from transpyle.fortran.compiler_interface import GfortranInterface, PgifortranInterface
13+
from transpyle.general import AstGeneralizer, Binder, CodeReader, Compiler, Parser, Unparser
14+
try:
15+
from transpyle.fortran.parser import FortranParser
16+
except ImportError:
17+
pass
18+
try:
19+
from transpyle.fortran.ast_generalizer import FortranAstGeneralizer
20+
except ImportError:
21+
pass
22+
try:
23+
from transpyle.fortran.unparser import Fortran77Unparser
24+
except ImportError:
25+
pass
26+
try:
27+
from transpyle.fortran.compiler import F2PyCompiler
28+
except ImportError:
29+
pass
30+
try:
31+
from transpyle.fortran.compiler_interface import GfortranInterface, PgifortranInterface
32+
except ImportError:
33+
pass
2034

2135
from .common import \
2236
random_data, EXAMPLES_ROOT, EXAMPLES_ROOTS, PERFORMANCE_RESULTS_ROOT, \
@@ -32,6 +46,7 @@
3246
MB = 1024 * KB
3347

3448

49+
@unittest.skipIf(Parser.find('Fortran') is None, 'skipping due to missing Fortran language support')
3550
class ParserTests(unittest.TestCase):
3651

3752
@execute_on_language_examples('f77', 'f95')
@@ -51,6 +66,8 @@ def test_try_parse_invalid(self):
5166
_LOG.debug('%s', err.exception)
5267

5368

69+
@unittest.skipIf(
70+
AstGeneralizer.find('Fortran') is None, 'skipping due to missing Fortran language support')
5471
class AstGeneralizerTests(unittest.TestCase):
5572

5673
@execute_on_language_examples('f77', 'f95')
@@ -65,6 +82,8 @@ def test_generalize_examples(self, input_path):
6582
_LOG.info('generalized "%s" in %fs', input_path, timer.elapsed)
6683

6784

85+
@unittest.skipIf(
86+
Unparser.find('Fortran') is None, 'skipping due to missing Fortran language support')
6887
class UnparserTests(unittest.TestCase):
6988

7089
@execute_on_language_fundamentals('f77', 'f95')
@@ -82,6 +101,8 @@ def test_unparse_fundamentals(self, input_path):
82101
_LOG.info('unparsed "%s" in %fs', input_path, timer.elapsed)
83102

84103

104+
@unittest.skipIf(
105+
Compiler.find('Fortran') is None, 'skipping due to missing Fortran language support')
85106
class CompilerTests(unittest.TestCase):
86107

87108
@execute_on_language_examples('f77', 'f95', predicate_not=accelerated)

0 commit comments

Comments
 (0)