2
2
import pytest
3
3
4
4
import numpy as np
5
- from numpy .testing import assert_raises , assert_equal
5
+ from numpy .testing import assert_ , assert_raises , assert_equal , assert_string_equal
6
6
7
7
from . import util
8
8
@@ -25,3 +25,23 @@ def test_inout(self):
25
25
x = np .arange (3 , dtype = np .float32 )
26
26
self .module .foo(x )
27
27
assert_equal (x , [3 , 1 , 2 ])
28
+
29
+
30
+ class TestNumpyVersionAttribute (util .F2PyTest ):
31
+ # Check that th attribute __f2py_numpy_version__ is present
32
+ # in the compiled module and that has the value np.__version__.
33
+ sources = [_path ('src' , 'regression' , 'inout.f90' )]
34
+
35
+ @pytest .mark .slow
36
+ def test_numpy_version_attribute (self ):
37
+
38
+ # Check that self.module has an attribute named "__f2py_numpy_version__"
39
+ assert_ (hasattr (self .module , "__f2py_numpy_version__" ),
40
+ msg = "Fortran module does not have __f2py_numpy_version__" )
41
+
42
+ # Check that the attribute __f2py_numpy_version__ is a string
43
+ assert_ (isinstance (self .module .__f2py_numpy_version__ , str ),
44
+ msg = "__f2py_numpy_version__ is not a string" )
45
+
46
+ # Check that __f2py_numpy_version__ has the value numpy.__version__
47
+ assert_string_equal (np .__version__ , self .module .__f2py_numpy_version__ )
0 commit comments