diff options
author | Armin Rigo <arigo@tunes.org> | 2013-04-15 19:13:23 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2013-04-15 19:13:23 +0200 |
commit | bc8cfed850c5d80aa839165de68b7afdca728dad (patch) | |
tree | 45a6fb784a1ae2af4d1e9c6b20619e03dcf53695 /testing/test_function.py | |
parent | b4b8d41a54ac514dcf5c67ec296c9c790b675b95 (diff) | |
download | cffi-bc8cfed850c5d80aa839165de68b7afdca728dad.tar.gz |
Fix for issue 77: give cdatas __module__, __name__ and __doc__ attributes,
for convenience with functools.wraps().
Diffstat (limited to 'testing/test_function.py')
-rw-r--r-- | testing/test_function.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/test_function.py b/testing/test_function.py index 430c46e..d3977f2 100644 --- a/testing/test_function.py +++ b/testing/test_function.py @@ -365,3 +365,19 @@ class TestFunction(object): """) m = ffi.dlopen("m") assert not hasattr(m, 'nonexistent') + + def test_wraps_from_stdlib(self): + import functools + ffi = FFI(backend=self.Backend()) + ffi.cdef(""" + double sin(double x); + """) + def my_decorator(f): + @functools.wraps(f) + def wrapper(*args): + return f(*args) + 100 + return wrapper + m = ffi.dlopen("m") + sin100 = my_decorator(m.sin) + x = sin100(1.23) + assert x == math.sin(1.23) + 100 |