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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import unittest
  6. import pythoncom
  7. from win32com.client import Dispatch
  8. from win32com.client.gencache import EnsureDispatch
  9.  
  10. class PippoTester(unittest.TestCase):
  11.     
  12.     def setUp(self):
  13.         import pippo_server
  14.         pippo_server.main([
  15.             pippo_server.__file__])
  16.         self.object = Dispatch('Python.Test.Pippo')
  17.  
  18.     
  19.     def testLeaks(self):
  20.         
  21.         try:
  22.             gtrc = sys.gettotalrefcount
  23.         except AttributeError:
  24.             print 'Please run this with python_d for leak tests'
  25.             
  26.             gtrc = lambda : 0
  27.  
  28.         self.object.Method1()
  29.         start = gtrc()
  30.         for i in range(1000):
  31.             object = Dispatch('Python.Test.Pippo')
  32.             object.Method1()
  33.         
  34.         object = None
  35.         end = gtrc()
  36.         if end - start > 5:
  37.             self.fail('We lost %d references!' % (end - start,))
  38.         
  39.  
  40.     
  41.     def testResults(self):
  42.         (rc, out1) = self.object.Method2(123, 111)
  43.         self.failUnlessEqual(rc, 123)
  44.         self.failUnlessEqual(out1, 222)
  45.  
  46.     
  47.     def testLeaksGencache(self):
  48.         
  49.         try:
  50.             gtrc = sys.gettotalrefcount
  51.         except AttributeError:
  52.             print 'Please run this with python_d for leak tests'
  53.             
  54.             gtrc = lambda : 0
  55.  
  56.         object = EnsureDispatch('Python.Test.Pippo')
  57.         start = gtrc()
  58.         for i in range(1000):
  59.             object = EnsureDispatch('Python.Test.Pippo')
  60.             object.Method1()
  61.         
  62.         object = None
  63.         end = gtrc()
  64.         if end - start > 10:
  65.             self.fail('We lost %d references!' % (end - start,))
  66.         
  67.  
  68.  
  69. if __name__ == '__main__':
  70.     unittest.main()
  71.  
  72.