home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_395 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.8 KB  |  76 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import unittest
  5. from ctypes import *
  6. import _ctypes_test
  7.  
  8. class ValuesTestCase(unittest.TestCase):
  9.     
  10.     def test_an_integer(self):
  11.         ctdll = CDLL(_ctypes_test.__file__)
  12.         an_integer = c_int.in_dll(ctdll, 'an_integer')
  13.         x = an_integer.value
  14.         self.failUnlessEqual(x, ctdll.get_an_integer())
  15.         an_integer.value *= 2
  16.         self.failUnlessEqual(x * 2, ctdll.get_an_integer())
  17.  
  18.     
  19.     def test_undefined(self):
  20.         ctdll = CDLL(_ctypes_test.__file__)
  21.         self.assertRaises(ValueError, c_int.in_dll, ctdll, 'Undefined_Symbol')
  22.  
  23.     
  24.     class Win_ValuesTestCase(unittest.TestCase):
  25.         
  26.         def test_optimizeflag(self):
  27.             opt = c_int.in_dll(pydll, 'Py_OptimizeFlag').value
  28.             if ValuesTestCase.__doc__ is not None:
  29.                 self.failUnlessEqual(opt, 1)
  30.             else:
  31.                 self.failUnlessEqual(opt, 2)
  32.  
  33.         
  34.         def test_frozentable(self):
  35.             
  36.             class struct_frozen(Structure):
  37.                 _fields_ = [
  38.                     ('name', c_char_p),
  39.                     ('code', POINTER(c_ubyte)),
  40.                     ('size', c_int)]
  41.  
  42.             FrozenTable = POINTER(struct_frozen)
  43.             ft = FrozenTable.in_dll(pydll, 'PyImport_FrozenModules')
  44.             items = []
  45.             for entry in ft:
  46.                 if entry.name is None:
  47.                     break
  48.                 
  49.                 items.append((entry.name, entry.size))
  50.             
  51.             import sys
  52.             if sys.version_info[:2] >= (2, 3):
  53.                 expected = [
  54.                     ('__hello__', 104),
  55.                     ('__phello__', -104),
  56.                     ('__phello__.spam', 104)]
  57.             else:
  58.                 expected = [
  59.                     ('__hello__', 100),
  60.                     ('__phello__', -100),
  61.                     ('__phello__.spam', 100)]
  62.             self.failUnlessEqual(items, expected)
  63.             _pointer_type_cache = _pointer_type_cache
  64.             import ctypes
  65.             del _pointer_type_cache[struct_frozen]
  66.  
  67.         
  68.         def test_undefined(self):
  69.             self.assertRaises(ValueError, c_int.in_dll, pydll, 'Undefined_Symbol')
  70.  
  71.  
  72.  
  73. if __name__ == '__main__':
  74.     unittest.main()
  75.  
  76.