home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import unittest
- from ctypes import *
- import _ctypes_test
-
- class ValuesTestCase(unittest.TestCase):
-
- def test_an_integer(self):
- ctdll = CDLL(_ctypes_test.__file__)
- an_integer = c_int.in_dll(ctdll, 'an_integer')
- x = an_integer.value
- self.failUnlessEqual(x, ctdll.get_an_integer())
- an_integer.value *= 2
- self.failUnlessEqual(x * 2, ctdll.get_an_integer())
-
-
- def test_undefined(self):
- ctdll = CDLL(_ctypes_test.__file__)
- self.assertRaises(ValueError, c_int.in_dll, ctdll, 'Undefined_Symbol')
-
-
- class Win_ValuesTestCase(unittest.TestCase):
-
- def test_optimizeflag(self):
- opt = c_int.in_dll(pydll, 'Py_OptimizeFlag').value
- if ValuesTestCase.__doc__ is not None:
- self.failUnlessEqual(opt, 1)
- else:
- self.failUnlessEqual(opt, 2)
-
-
- def test_frozentable(self):
-
- class struct_frozen(Structure):
- _fields_ = [
- ('name', c_char_p),
- ('code', POINTER(c_ubyte)),
- ('size', c_int)]
-
- FrozenTable = POINTER(struct_frozen)
- ft = FrozenTable.in_dll(pydll, 'PyImport_FrozenModules')
- items = []
- for entry in ft:
- if entry.name is None:
- break
-
- items.append((entry.name, entry.size))
-
- import sys
- if sys.version_info[:2] >= (2, 3):
- expected = [
- ('__hello__', 104),
- ('__phello__', -104),
- ('__phello__.spam', 104)]
- else:
- expected = [
- ('__hello__', 100),
- ('__phello__', -100),
- ('__phello__.spam', 100)]
- self.failUnlessEqual(items, expected)
- _pointer_type_cache = _pointer_type_cache
- import ctypes
- del _pointer_type_cache[struct_frozen]
-
-
- def test_undefined(self):
- self.assertRaises(ValueError, c_int.in_dll, pydll, 'Undefined_Symbol')
-
-
-
- if __name__ == '__main__':
- unittest.main()
-
-