[pypy-commit] pypy default: add test for last change

gutworth noreply at buildbot.pypy.org
Mon Mar 12 03:19:16 CET 2012


Author: Benjamin Peterson <benjamin at python.org>
Branch: 
Changeset: r53310:9e128382ae65
Date: 2012-03-11 19:18 -0700
http://bitbucket.org/pypy/pypy/changeset/9e128382ae65/

Log:	add test for last change

diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_errno.py b/pypy/module/test_lib_pypy/ctypes_tests/test_errno.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_errno.py
@@ -0,0 +1,21 @@
+import py
+
+import ctypes
+from _ctypes import function
+
+_rawffi = py.test.importorskip("_rawffi")
+
+class TestErrno:
+
+    def test_errno_saved_and_restored(self):
+        def check():
+            assert _rawffi.get_errno() == 42
+            assert ctypes.get_errno() == old
+        check.free_temp_buffers = lambda *args: None
+        f = function.CFuncPtr()
+        old = _rawffi.get_errno()
+        f._flags_ = _rawffi.FUNCFLAG_USE_ERRNO
+        ctypes.set_errno(42)
+        f._call_funcptr(check)
+        assert _rawffi.get_errno() == old
+        ctypes.set_errno(0)


More information about the pypy-commit mailing list