diff options
Diffstat (limited to 'numpy/f2py/tests/test_callback.py')
-rw-r--r-- | numpy/f2py/tests/test_callback.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/numpy/f2py/tests/test_callback.py b/numpy/f2py/tests/test_callback.py index b3f21d351..6824a2042 100644 --- a/numpy/f2py/tests/test_callback.py +++ b/numpy/f2py/tests/test_callback.py @@ -7,6 +7,7 @@ from numpy import array from numpy.testing import run_module_suite, assert_, assert_equal, dec import util + class TestF77Callback(util.F2PyTest): code = """ subroutine t(fun,a) @@ -85,35 +86,38 @@ cf2py intent(out) a def check_function(self, name): t = getattr(self.module, name) - r = t(lambda : 4) - assert_( r==4, repr(r)) - r = t(lambda a:5, fun_extra_args=(6,)) - assert_( r==5, repr(r)) - r = t(lambda a:a, fun_extra_args=(6,)) - assert_( r==6, repr(r)) - r = t(lambda a:5+a, fun_extra_args=(7,)) - assert_( r==12, repr(r)) - r = t(lambda a:math.degrees(a), fun_extra_args=(math.pi,)) - assert_( r==180, repr(r)) + r = t(lambda: 4) + assert_(r == 4, repr(r)) + r = t(lambda a: 5, fun_extra_args=(6,)) + assert_(r == 5, repr(r)) + r = t(lambda a: a, fun_extra_args=(6,)) + assert_(r == 6, repr(r)) + r = t(lambda a: 5 + a, fun_extra_args=(7,)) + assert_(r == 12, repr(r)) + r = t(lambda a: math.degrees(a), fun_extra_args=(math.pi,)) + assert_(r == 180, repr(r)) r = t(math.degrees, fun_extra_args=(math.pi,)) - assert_( r==180, repr(r)) + assert_(r == 180, repr(r)) r = t(self.module.func, fun_extra_args=(6,)) - assert_( r==17, repr(r)) + assert_(r == 17, repr(r)) r = t(self.module.func0) - assert_( r==11, repr(r)) + assert_(r == 11, repr(r)) r = t(self.module.func0._cpointer) - assert_( r==11, repr(r)) + assert_(r == 11, repr(r)) + class A(object): + def __call__(self): return 7 + def mth(self): return 9 a = A() r = t(a) - assert_( r==7, repr(r)) + assert_(r == 7, repr(r)) r = t(a.mth) - assert_( r==9, repr(r)) + assert_(r == 9, repr(r)) def test_string_callback(self): |