Debian Codegraph @

extra_tests/ctypes_tests/test_errno.py

raw symbols SCIP
1 import pytest
2
3 import ctypes
4 _rawffi = pytest.importorskip('_rawffi') # PyPy-only
5
6 def test_errno_saved_and_restored():
7 def check():
8 assert _rawffi.get_errno() == 42
9 assert ctypes.get_errno() == old
10 check.free_temp_buffers = lambda *args: None
11 f = ctypes._CFuncPtr()
12 old = _rawffi.get_errno()
13 f._flags_ = _rawffi.FUNCFLAG_USE_ERRNO
14 ctypes.set_errno(42)
15 f._call_funcptr(check)
16 assert _rawffi.get_errno() == old
17 ctypes.set_errno(0)
18
19 # see also test_functions.test_errno