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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from ctypes import *
  5. from ctypes.test import is_resource_enabled
  6. import unittest
  7. import sys
  8. import _ctypes_test
  9. if sys.platform == 'win32' and sizeof(c_void_p) == sizeof(c_int):
  10.     
  11.     class WindowsTestCase(unittest.TestCase):
  12.         
  13.         def test_callconv_1(self):
  14.             IsWindow = windll.user32.IsWindow
  15.             self.assertRaises(ValueError, IsWindow)
  16.             self.failUnlessEqual(0, IsWindow(0))
  17.             self.assertRaises(ValueError, IsWindow, 0, 0, 0)
  18.  
  19.         
  20.         def test_callconv_2(self):
  21.             IsWindow = cdll.user32.IsWindow
  22.             self.assertRaises(ValueError, IsWindow, None)
  23.  
  24.  
  25.  
  26. if sys.platform == 'win32':
  27.     
  28.     class FunctionCallTestCase(unittest.TestCase):
  29.         if is_resource_enabled('SEH'):
  30.             
  31.             def test_SEH(self):
  32.                 self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
  33.  
  34.         
  35.         
  36.         def test_noargs(self):
  37.             windll.user32.GetDesktopWindow()
  38.  
  39.  
  40.     
  41.     class TestWintypes(unittest.TestCase):
  42.         
  43.         def test_HWND(self):
  44.             wintypes = wintypes
  45.             import ctypes
  46.             self.failUnlessEqual(sizeof(wintypes.HWND), sizeof(c_void_p))
  47.  
  48.         
  49.         def test_PARAM(self):
  50.             wintypes = wintypes
  51.             import ctypes
  52.             self.failUnlessEqual(sizeof(wintypes.WPARAM), sizeof(c_void_p))
  53.             self.failUnlessEqual(sizeof(wintypes.LPARAM), sizeof(c_void_p))
  54.  
  55.         
  56.         def test_COMError(self):
  57.             COMError = COMError
  58.             import _ctypes
  59.             self.assertEqual(COMError.__doc__, 'Raised when a COM method call failed.')
  60.             ex = COMError(-1, 'text', ('details',))
  61.             self.assertEqual(ex.hresult, -1)
  62.             self.assertEqual(ex.text, 'text')
  63.             self.assertEqual(ex.details, ('details',))
  64.  
  65.  
  66.  
  67.  
  68. class Structures(unittest.TestCase):
  69.     
  70.     def test_struct_by_value(self):
  71.         
  72.         class POINT(Structure):
  73.             _fields_ = [
  74.                 ('x', c_long),
  75.                 ('y', c_long)]
  76.  
  77.         
  78.         class RECT(Structure):
  79.             _fields_ = [
  80.                 ('left', c_long),
  81.                 ('top', c_long),
  82.                 ('right', c_long),
  83.                 ('bottom', c_long)]
  84.  
  85.         dll = CDLL(_ctypes_test.__file__)
  86.         pt = POINT(10, 10)
  87.         rect = RECT(0, 0, 20, 20)
  88.         self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
  89.  
  90.  
  91. if __name__ == '__main__':
  92.     unittest.main()
  93.  
  94.