PATH:
lib64
/
python2.7
/
ctypes
/
test
import unittest import pickle from ctypes import * import _ctypes_test dll = CDLL(_ctypes_test.__file__) class X(Structure): _fields_ = [("a", c_int), ("b", c_double)] init_called = 0 def __init__(self, *args, **kw): X.init_called += 1 self.x = 42 class Y(X): _fields_ = [("str", c_char_p)] class PickleTest: def dumps(self, item): return pickle.dumps(item, self.proto) def loads(self, item): return pickle.loads(item) def test_simple(self): for src in [ c_int(42), c_double(3.14), ]: dst = self.loads(self.dumps(src)) self.assertEqual(src.__dict__, dst.__dict__) self.assertEqual(memoryview(src).tobytes(), memoryview(dst).tobytes()) def test_struct(self): X.init_called = 0 x = X() x.a = 42 self.assertEqual(X.init_called, 1) y = self.loads(self.dumps(x)) # loads must NOT call __init__ self.assertEqual(X.init_called, 1) # ctypes instances are identical when the instance __dict__ # and the memory buffer are identical self.assertEqual(y.__dict__, x.__dict__) self.assertEqual(memoryview(y).tobytes(), memoryview(x).tobytes()) def test_unpickable(self): # ctypes objects that are pointers or contain pointers are # unpickable. self.assertRaises(ValueError, lambda: self.dumps(Y())) prototype = CFUNCTYPE(c_int) for item in [ c_char_p(), c_wchar_p(), c_void_p(), pointer(c_int(42)), dll._testfunc_p_p, prototype(lambda: 42), ]: self.assertRaises(ValueError, lambda: self.dumps(item)) def test_wchar(self): self.dumps(c_char(b"x")) # Issue 5049 self.dumps(c_wchar(u"x")) for proto in range(pickle.HIGHEST_PROTOCOL + 1): name = 'PickleTest_%s' % proto globals()[name] = type(name, (PickleTest, unittest.TestCase), {'proto': proto}) if __name__ == "__main__": unittest.main()
[+]
..
[-] test_values.pyc
[open]
[-] runtests.pyc
[open]
[-] test_objects.pyc
[open]
[-] test_checkretval.pyc
[open]
[-] test_find.pyo
[open]
[-] test_macholib.py
[open]
[-] test_loading.pyo
[open]
[-] test_wintypes.pyo
[open]
[-] test_win32.py
[open]
[-] test_loading.pyc
[open]
[-] test_frombuffer.pyo
[open]
[-] test_returnfuncptrs.py
[open]
[-] test_sizes.pyc
[open]
[-] test_libc.pyc
[open]
[-] test_libc.pyo
[open]
[-] test_random_things.py
[open]
[-] test_as_parameter.pyo
[open]
[-] test_refcounts.pyo
[open]
[-] test_random_things.pyc
[open]
[-] test_numbers.py
[open]
[-] test_pickling.pyo
[open]
[-] test_values.pyo
[open]
[-] test_simplesubclasses.pyo
[open]
[-] test_repr.py
[open]
[-] test_cfuncs.pyc
[open]
[-] test_structures.pyo
[open]
[-] test_incomplete.pyo
[open]
[-] test_frombuffer.pyc
[open]
[-] test_byteswap.py
[open]
[-] test_pickling.pyc
[open]
[-] test_parameters.py
[open]
[-] test_macholib.pyc
[open]
[-] test_array_in_pointer.pyo
[open]
[-] test_repr.pyo
[open]
[-] test_delattr.pyo
[open]
[-] test_callbacks.pyc
[open]
[-] test_strings.pyo
[open]
[-] test_funcptr.pyc
[open]
[-] test_byteswap.pyo
[open]
[-] test_frombuffer.py
[open]
[-] test_find.py
[open]
[-] test_anon.pyc
[open]
[-] test_errno.pyc
[open]
[-] test_pep3118.pyo
[open]
[-] test_funcptr.py
[open]
[-] test_strings.pyc
[open]
[-] test_cfuncs.py
[open]
[-] test_array_in_pointer.py
[open]
[-] test_bitfields.pyc
[open]
[-] test_python_api.pyc
[open]
[-] test_unicode.pyo
[open]
[-] test_anon.pyo
[open]
[-] test_slicing.pyc
[open]
[-] test_refcounts.pyc
[open]
[-] runtests.pyo
[open]
[-] test_pointers.pyo
[open]
[-] test_delattr.pyc
[open]
[-] __init__.pyc
[open]
[-] test_prototypes.pyc
[open]
[-] test_cast.pyo
[open]
[-] test_checkretval.pyo
[open]
[-] test_pep3118.py
[open]
[-] test_wintypes.pyc
[open]
[-] test_sizes.py
[open]
[-] test_numbers.pyc
[open]
[-] test_varsize_struct.pyo
[open]
[-] test_internals.py
[open]
[-] test_objects.py
[open]
[-] test_anon.py
[open]
[-] test_struct_fields.py
[open]
[-] test_functions.pyo
[open]
[-] test_libc.py
[open]
[-] test_struct_fields.pyc
[open]
[-] test_random_things.pyo
[open]
[-] test_arrays.pyc
[open]
[-] test_memfunctions.py
[open]
[-] test_python_api.pyo
[open]
[-] test_incomplete.pyc
[open]
[-] test_returnfuncptrs.pyo
[open]
[-] test_array_in_pointer.pyc
[open]
[-] test_structures.pyc
[open]
[-] test_errno.py
[open]
[-] test_returnfuncptrs.pyc
[open]
[-] test_as_parameter.pyc
[open]
[-] test_keeprefs.pyo
[open]
[-] test_memfunctions.pyc
[open]
[-] test_pep3118.pyc
[open]
[-] test_parameters.pyo
[open]
[-] test_cast.pyc
[open]
[-] test_simplesubclasses.py
[open]
[-] test_internals.pyc
[open]
[-] test_keeprefs.py
[open]
[-] test_pointers.py
[open]
[-] test_bitfields.pyo
[open]
[-] test_macholib.pyo
[open]
[-] test_refcounts.py
[open]
[-] test_values.py
[open]
[-] test_checkretval.py
[open]
[-] test_arrays.py
[open]
[-] test_buffers.pyc
[open]
[-] test_python_api.py
[open]
[-] test_strings.py
[open]
[-] test_unicode.pyc
[open]
[-] test_parameters.pyc
[open]
[-] test_buffers.pyo
[open]
[-] test_cfuncs.pyo
[open]
[-] test_prototypes.pyo
[open]
[-] test_keeprefs.pyc
[open]
[-] test_stringptr.pyc
[open]
[-] test_unicode.py
[open]
[-] test_struct_fields.pyo
[open]
[-] test_cast.py
[open]
[-] test_slicing.pyo
[open]
[-] test_buffers.py
[open]
[-] test_prototypes.py
[open]
[-] test_internals.pyo
[open]
[-] test_unaligned_structures.py
[open]
[-] test_functions.pyc
[open]
[-] test_stringptr.pyo
[open]
[-] test_repr.pyc
[open]
[-] __init__.py
[open]
[-] test_numbers.pyo
[open]
[-] test_init.pyc
[open]
[-] test_errno.pyo
[open]
[-] test_structures.py
[open]
[-] test_win32.pyo
[open]
[-] test_varsize_struct.pyc
[open]
[-] test_byteswap.pyc
[open]
[-] test_stringptr.py
[open]
[-] test_arrays.pyo
[open]
[-] test_slicing.py
[open]
[-] test_loading.py
[open]
[-] test_delattr.py
[open]
[-] test_objects.pyo
[open]
[-] test_init.pyo
[open]
[-] test_varsize_struct.py
[open]
[-] test_init.py
[open]
[-] test_memfunctions.pyo
[open]
[-] test_as_parameter.py
[open]
[-] test_incomplete.py
[open]
[-] test_simplesubclasses.pyc
[open]
[-] test_bitfields.py
[open]
[-] test_callbacks.py
[open]
[-] test_win32.pyc
[open]
[-] test_unaligned_structures.pyo
[open]
[-] test_unaligned_structures.pyc
[open]
[-] test_sizes.pyo
[open]
[-] test_funcptr.pyo
[open]
[-] __init__.pyo
[open]
[-] test_pointers.pyc
[open]
[-] runtests.py
[open]
[-] test_find.pyc
[open]
[-] test_callbacks.pyo
[open]
[-] test_wintypes.py
[open]
[-] test_functions.py
[open]
[-] test_pickling.py
[open]