testAXScript.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Test AXScripting the best we can in an automated fashion...
  2. import win32api, os, sys
  3. import win32com.axscript
  4. import win32com.axscript.client
  5. import unittest
  6. import win32com.test.util
  7. verbose = "-v" in sys.argv
  8. class AXScript(win32com.test.util.TestCase):
  9. def setUp(self):
  10. file = win32api.GetFullPathName(os.path.join(win32com.axscript.client.__path__[0], "pyscript.py"))
  11. from win32com.test.util import RegisterPythonServer
  12. self.verbose = verbose
  13. RegisterPythonServer(file, 'python', verbose=self.verbose)
  14. def testHost(self):
  15. file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "test\\testHost.py"))
  16. cmd = '%s "%s"' % (win32api.GetModuleFileName(0), file)
  17. if verbose:
  18. print("Testing Python Scripting host")
  19. win32com.test.util.ExecuteShellCommand(cmd, self)
  20. def testCScript(self):
  21. file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "Demos\\Client\\wsh\\test.pys"))
  22. cmd = 'cscript.exe "%s"' % (file)
  23. if verbose:
  24. print("Testing Windows Scripting host with Python script")
  25. win32com.test.util.ExecuteShellCommand(cmd, self)
  26. if __name__=='__main__':
  27. win32com.test.util.testmain()