[commit] r1766 - in trunk/Tests/GPyUnit: . GME_297 GME_310 Regr/Mga Regr/Mga/utils Samples util

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Jan 4 14:35:02 CST 2012


Author: ksmyth
Date: Wed Jan  4 14:35:02 2012
New Revision: 1766

Log:
Fixes for x64 testing

Modified:
   trunk/Tests/GPyUnit/GME_297/__init__.py
   trunk/Tests/GPyUnit/GME_310/__init__.py
   trunk/Tests/GPyUnit/GME_371.py
   trunk/Tests/GPyUnit/Regr/Mga/tc1.py
   trunk/Tests/GPyUnit/Regr/Mga/utils/mga2xme.py
   trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py
   trunk/Tests/GPyUnit/Samples/gmeutils.py
   trunk/Tests/GPyUnit/__init__.py
   trunk/Tests/GPyUnit/__main__.py
   trunk/Tests/GPyUnit/test_gmeoleapp.py
   trunk/Tests/GPyUnit/test_registrar.py
   trunk/Tests/GPyUnit/test_registry.py
   trunk/Tests/GPyUnit/util/__init__.py

Modified: trunk/Tests/GPyUnit/GME_297/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_297/__init__.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/GME_297/__init__.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -4,7 +4,7 @@
 import sys
 import os.path
 import unittest
-import win32com.client
+from GPyUnit.util import DispatchEx
 
 class TestRefportConnectionInvariantUnderMoves(unittest.TestCase):
     def __init__(self, input_file, fco_to_move, destination_model, name=None, use_disp=None, **kwds):
@@ -30,16 +30,16 @@
         from GPyUnit import util
         util.register_xmp(_adjacent_file('GME297ModelRefportTest.xmp'))
         with util.disable_early_binding():
-            self.project = win32com.client.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Open("MGA=" + _adjacent_file(self.input_file))
             self.territory = self.project.BeginTransactionInNewTerr()
 
             fco_to_move = self.project.ObjectByPath(self.fco_to_move)
             OBJTYPE_FOLDER = 6
             if fco_to_move.ObjType == OBJTYPE_FOLDER:
-                tomove = win32com.client.DispatchEx("Mga.MgaFolders")
+                tomove = DispatchEx("Mga.MgaFolders")
             else:
-                tomove = win32com.client.DispatchEx("Mga.MgaFCOs")
+                tomove = DispatchEx("Mga.MgaFCOs")
             tomove.Append(fco_to_move)
 
             destination = self.project.ObjectByPath(self.destination_model)

Modified: trunk/Tests/GPyUnit/GME_310/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_310/__init__.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/GME_310/__init__.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -4,7 +4,7 @@
 import sys
 import os.path
 import unittest
-import win32com.client
+from GPyUnit.util import DispatchEx
 
 class TestFolderCopy(unittest.TestCase):
     def __init__(self, input_file, folder_to_copy, destination_folder, name=None, **kwds):
@@ -28,13 +28,13 @@
         util.register_xmp(_adjacent_file('GME310ModelRefportTest.xmp'))
 
         with util.disable_early_binding():
-            self.project = win32com.client.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Open("MGA=" + _adjacent_file(self.input_file))
             self.territory = self.project.BeginTransactionInNewTerr()
 
             modelb = self.project.ObjectByPath(self.folder_to_copy)
             modelb.Name
-            tomove = win32com.client.DispatchEx("Mga.MgaFolders")
+            tomove = DispatchEx("Mga.MgaFolders")
             tomove.Append(modelb)
             #self.project.ObjectByPath(self.destination_folder).CopyFolders(tomove, None)
             self.project.RootFolder.CopyFolderDisp(modelb)

Modified: trunk/Tests/GPyUnit/GME_371.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_371.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/GME_371.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -1,14 +1,14 @@
 import unittest
 import os
+from GPyUnit.util import DispatchEx
 
 class TestParser(unittest.TestCase):
     def test_ParseMetaGME(self):
         testdir = os.path.dirname(os.path.abspath(__file__))
         inputfile = os.environ['GME_ROOT'] + r"\Paradigms\MetaGME\MetaGME-model.xme"
-        import win32com.client
-        xme = win32com.client.DispatchEx("Mga.MgaParser")
+        xme = DispatchEx("Mga.MgaParser")
         (paradigm, parversion, parguid, basename, ver) = xme.GetXMLInfo(inputfile)
-        mga = win32com.client.DispatchEx("Mga.MgaProject")
+        mga = DispatchEx("Mga.MgaProject")
 
         mga.Create("MGA=tmp.mga", paradigm)
         terr = mga.BeginTransactionInNewTerr()

Modified: trunk/Tests/GPyUnit/Regr/Mga/tc1.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/tc1.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/Regr/Mga/tc1.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -3,6 +3,7 @@
 import os
 import GPyUnit.Regr.Mga.utils.Builder
 bd = GPyUnit.Regr.Mga.utils.Builder
+from GPyUnit.util import DispatchEx
 
 from GPyUnit.util import dec_disable_early_binding
 
@@ -243,7 +244,7 @@
 		#			 [in] IMgaFCOs *srcrefs, [in] IMgaFCOs *dstrefs, [out] IMgaFCO **newobj);
 		
 		# this dummy collection will be used for those connections which do not involve connections
-		z0 = win32com.client.DispatchEx("Mga.MgaFCOs")
+		z0 = DispatchEx("Mga.MgaFCOs")
 		
 		try:
 		 # create a containment relation between atom1 and model1
@@ -454,7 +455,7 @@
 		portOpB.Name = 'OpB1'
 
 		# this dummy collection will be used for those connections which do not involve connections
-		z0 = win32com.client.DispatchEx("Mga.MgaFCOs")
+		z0 = DispatchEx("Mga.MgaFCOs")
 		
 		try:
 		 # create a DFC relation between is1 and os1

Modified: trunk/Tests/GPyUnit/Regr/Mga/utils/mga2xme.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/utils/mga2xme.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/Regr/Mga/utils/mga2xme.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -3,7 +3,7 @@
 # the .xme files are placed into the directory specified by the 2nd parameter
 
 import sys
-import win32com.client
+from GPyUnit.util import DispatchEx
 import os
 
 def mgafiles( dir, begin_pattern = "", end_pattern = "" ):
@@ -39,7 +39,7 @@
 		xmename = os.path.abspath( os.path.join( os.path.curdir, xmename))
 
 		try:
-			gme = win32com.client.Dispatch("GME.Application")
+			gme = DispatchEx("GME.Application")
 			gme.Visible = 0
 			gme.OpenProject( "MGA=" + mganame )
 			

Modified: trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -7,7 +7,7 @@
 #
 #
 import sys
-import win32com.client
+from GPyUnit.util import DispatchEx
 import os
 
 def xmefiles( dir, begin_pattern = "", end_pattern = "" ):
@@ -43,7 +43,7 @@
 		xmename = os.path.abspath( os.path.join( os.path.curdir, i))
 
 		try:
-			gme = win32com.client.Dispatch("GME.Application")
+			gme = DispatchEx("GME.Application")
 			gme.Visible = 0
 			
 			paradigm = "MetaGME"

Modified: trunk/Tests/GPyUnit/Samples/gmeutils.py
==============================================================================
--- trunk/Tests/GPyUnit/Samples/gmeutils.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/Samples/gmeutils.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -1,7 +1,7 @@
 """
 Helper methods for developing Python testcases for GME
 """
-import win32com.client
+from GPyUnit.util import DispatchEx
 import os
 
 regNodePositionStartTag = '<regnode name="PartRegs"'
@@ -92,7 +92,7 @@
             xmename = mganame + '.xme'
 
         try:
-                gme = win32com.client.Dispatch("GME.Application")
+                gme = DispatchEx("GME.Application")
         except:
                 raise 'Could not create GME.Application'
 

Modified: trunk/Tests/GPyUnit/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/__init__.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/__init__.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -21,7 +21,9 @@
 
 # it is also possible to run tests like this on Python 2.7:
 # python -m unittest GPyUnit.Regr.Mga.tc7
-_tests = [
+
+def _test_names():
+    _test_names = [
  'test_PIAs',
  'test_registrar',
  'test_gmeoleapp',
@@ -30,16 +32,35 @@
  'GME_297.suite',
  'GME_310.suite',
  'GME_371',
-'Regr.Mga.tc1',
 ]
 
-if platform.system() != 'Java':
-    _tests = _tests + [
-'Regr.Mga.tc2',
-'Regr.Mga.tc3',
-'Regr.Mga.tc5',
-'Regr.Mga.tc6',
-]
+    if not GPyUnit.util._opts.Dispatch_x64:
+        _test_names += [
+        'Regr.Mga.tc1',
+        ]
+        if platform.system() != 'Java':
+            _test_names += [
+            'Regr.Mga.tc2',
+            'Regr.Mga.tc3',
+            'Regr.Mga.tc5',
+            'Regr.Mga.tc6',
+            ]
+    return _test_names
+
+def _tests():
+    # print _test_names()
+    # can't find tc2 with \python27\python -m GPyUnit if we don't do this
+    import GPyUnit.Regr.Mga.tc2
+    return unittest.defaultTestLoader.loadTestsFromNames(['GPyUnit.' + test for test in _test_names()])
 
-_tests = unittest.defaultTestLoader.loadTestsFromNames(['GPyUnit.' + test for test in _tests])
+def run_xmlrunner(output_filename):
+    import os.path
+    import xmlrunner
+    results = []
+    with open(output_filename, "w") as output:
+        output.write("<testsuites>")
+        for test in GPyUnit._tests():
+            runner = xmlrunner.XMLTestRunner(output)
+            runner.run(test)
+        output.write("</testsuites>")
 

Modified: trunk/Tests/GPyUnit/__main__.py
==============================================================================
--- trunk/Tests/GPyUnit/__main__.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/__main__.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -12,18 +12,14 @@
     parser = optparse.OptionParser()
     parser.add_option("-x", "--xml", action="store_true", dest="xml")
     parser.add_option("-v", action="store_true", dest="verbose")
+    parser.add_option('-a', '--arch', dest='arch')
 
     (options, args) = parser.parse_args()
+    import GPyUnit.util
+    if options.arch and options.arch == 'x64':
+        GPyUnit.util._opts.Dispatch_x64 = True
     if options.xml:
-        import os.path
-        import xmlrunner
-        with open("tests.xml", "w") as output:
-            output.write("<testsuites>")
-            for test in GPyUnit._tests:
-                runner = xmlrunner.XMLTestRunner(output)
-                runner.run(test)
-            output.write("</testsuites>")
+        GPyUnit.run_xmlrunner('tests.xml')
     else:
         runner = unittest.TextTestRunner(verbosity=2 if options.verbose else 1)
-        runner.run(GPyUnit._tests)
-
+        runner.run(GPyUnit._tests())

Modified: trunk/Tests/GPyUnit/test_gmeoleapp.py
==============================================================================
--- trunk/Tests/GPyUnit/test_gmeoleapp.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/test_gmeoleapp.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -1,11 +1,12 @@
 from __future__ import with_statement
 
 import unittest
+from GPyUnit.util import DispatchEx
 
 class TestGMEOLEApp(unittest.TestCase):
     def test_Exit(self):
         import win32com.client
-        gme = win32com.client.DispatchEx("GME.Application")
+        gme = DispatchEx("GME.Application")
         gme.Version
         gme.Exit()
         # under _DEBUG, GME.exe does not exit until Release()ed
@@ -18,13 +19,13 @@
     def test_Console(self):
         import win32com.client
 
-        registrar = win32com.client.DispatchEx("Mga.MgaRegistrar")
+        registrar = DispatchEx("Mga.MgaRegistrar")
         registrar.SetScriptEngineDisp(1, "Python.AXScript.2")
         
         def _adjacent_file(file):
             import os.path
             return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
-        self.gme = win32com.client.DispatchEx("GME.Application")
+        self.gme = DispatchEx("GME.Application")
         self.gme.Version
         console = filter(lambda p: p.Name == "Console", self.gme.Panels)[0]
         intf = console.Interface

Modified: trunk/Tests/GPyUnit/test_registrar.py
==============================================================================
--- trunk/Tests/GPyUnit/test_registrar.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/test_registrar.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -1,9 +1,9 @@
 import unittest
+from GPyUnit.util import DispatchEx
 
 class TestRegistrar(unittest.TestCase):
 	def test_GetAssociatedParadigmsDisp(self):
-		import win32com.client
-		x = win32com.client.DispatchEx("MGA.MgaRegistrar")
+		x = DispatchEx("MGA.MgaRegistrar")
 		self.assertEqual(list(x.GetAssociatedParadigmsDisp("MGA.Interpreter.MetaInterpreter", 1)), [u'MetaGME'])
 
 #suite = (TestRegistrar(),)

Modified: trunk/Tests/GPyUnit/test_registry.py
==============================================================================
--- trunk/Tests/GPyUnit/test_registry.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/test_registry.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -5,7 +5,7 @@
 import unittest
 import GPyUnit.util
 import GPyUnit.util.gme
-import win32com.client
+from GPyUnit.util import DispatchEx
 
 def _adjacent_file(file):
     import os.path
@@ -29,7 +29,7 @@
         from GPyUnit import util
         util.register_xmp('MetaGME')
         with util.disable_early_binding():
-            self.project = GPyUnit.util.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Create(self.connstr, "MetaGME")
             self.project.BeginTransactionInNewTerr(0)
             
@@ -122,7 +122,7 @@
         from GPyUnit import util
         util.register_xmp('MetaGME')
         with util.disable_early_binding():
-            self.project = GPyUnit.util.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Create(self.connstr, "MetaGME")
             self.project.BeginTransactionInNewTerr()
             
@@ -151,7 +151,7 @@
         from GPyUnit import util
         util.register_xmp('MetaGME')
         with util.disable_early_binding():
-            self.project = GPyUnit.util.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Create(self.connstr, "MetaGME")
             self.project.BeginTransactionInNewTerr()
             
@@ -170,7 +170,7 @@
         from GPyUnit import util
         util.register_xmp('MetaGME')
         with util.disable_early_binding():
-            self.project = GPyUnit.util.DispatchEx("Mga.MgaProject")
+            self.project = DispatchEx("Mga.MgaProject")
             self.project.Open("MGA=" + r"C:\Users\ksmyth\Documents\META\meta\CyPhyML\CyPhyML.mga")
             self.project.BeginTransactionInNewTerr()
             self.project.RootFolder.ChildFolders

Modified: trunk/Tests/GPyUnit/util/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/util/__init__.py	Wed Jan  4 14:34:34 2012	(r1765)
+++ trunk/Tests/GPyUnit/util/__init__.py	Wed Jan  4 14:35:02 2012	(r1766)
@@ -13,6 +13,8 @@
     import win32com.client
     CLSCTX_ALL = 23
     CLSCTX_LOCAL_SERVER = 4
+    CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
+    CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
     if _opts.Dispatch_x64:
         return win32com.client.DispatchEx(progid, clsctx=CLSCTX_LOCAL_SERVER|CLSCTX_ACTIVATE_64_BIT_SERVER)
     else:


More information about the gme-commit mailing list