testServers.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import pythoncom, win32com.client.dynamic, sys
  2. import winerror
  3. import win32com.test.util
  4. import unittest
  5. def TestConnections():
  6. import win32com.demos.connect
  7. win32com.demos.connect.test()
  8. class InterpCase(win32com.test.util.TestCase):
  9. def setUp(self):
  10. # Ensure the correct version registered.
  11. from win32com.test.util import RegisterPythonServer
  12. from win32com.servers import interp
  13. RegisterPythonServer(interp.__file__, "Python.Interpreter")
  14. def _testInterp(self, interp):
  15. self.assertEquals(interp.Eval("1+1"), 2)
  16. win32com.test.util.assertRaisesCOM_HRESULT(self, winerror.DISP_E_TYPEMISMATCH,
  17. interp.Eval, 2)
  18. def testInproc(self):
  19. interp = win32com.client.dynamic.Dispatch("Python.Interpreter", clsctx = pythoncom.CLSCTX_INPROC)
  20. self._testInterp(interp)
  21. def testLocalServer(self):
  22. interp = win32com.client.dynamic.Dispatch("Python.Interpreter", clsctx = pythoncom.CLSCTX_LOCAL_SERVER)
  23. self._testInterp(interp)
  24. def testAny(self):
  25. interp = win32com.client.dynamic.Dispatch("Python.Interpreter")
  26. self._testInterp(interp)
  27. class ConnectionsTestCase(win32com.test.util.TestCase):
  28. def testConnections(self):
  29. TestConnections()
  30. if __name__=='__main__':
  31. unittest.main('testServers')