summaryrefslogtreecommitdiff
path: root/testing/cffi0/test_function.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2018-02-16 09:27:27 +0100
committerArmin Rigo <arigo@tunes.org>2018-02-16 09:27:27 +0100
commit10b51aec2ac55e31a254cec0959bd2ca2659b61a (patch)
tree5f5820dfc9183d1e3f31912319432ae922e2f77e /testing/cffi0/test_function.py
parentbb2645dbe2c021db1cbfb72fb32e79c0350aa42b (diff)
downloadcffi-10b51aec2ac55e31a254cec0959bd2ca2659b61a.tar.gz
Implement ffi.dlclose() for the in-line case
Diffstat (limited to 'testing/cffi0/test_function.py')
-rw-r--r--testing/cffi0/test_function.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/testing/cffi0/test_function.py b/testing/cffi0/test_function.py
index 61be656..077f806 100644
--- a/testing/cffi0/test_function.py
+++ b/testing/cffi0/test_function.py
@@ -499,3 +499,23 @@ class TestFunction(object):
""")
m = ffi.dlopen(lib_m)
assert dir(m) == ['MYE1', 'MYE2', 'MYFOO', 'myconst', 'myfunc', 'myvar']
+
+ def test_dlclose(self):
+ if self.Backend is CTypesBackend:
+ py.test.skip("not with the ctypes backend")
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("int foobar(void); int foobaz;")
+ lib = ffi.dlopen(lib_m)
+ ffi.dlclose(lib)
+ e = py.test.raises(ValueError, ffi.dlclose, lib)
+ assert str(e.value).startswith("library '")
+ assert str(e.value).endswith("' has already been closed")
+ e = py.test.raises(ValueError, getattr, lib, 'foobar')
+ assert str(e.value).startswith("library '")
+ assert str(e.value).endswith("' has already been closed")
+ e = py.test.raises(ValueError, getattr, lib, 'foobaz')
+ assert str(e.value).startswith("library '")
+ assert str(e.value).endswith("' has already been closed")
+ e = py.test.raises(ValueError, setattr, lib, 'foobaz', 42)
+ assert str(e.value).startswith("library '")
+ assert str(e.value).endswith("' has already been closed")