[commit] r1729 - in trunk/Tests/GPyUnit: . util

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Mon Dec 5 13:24:37 CST 2011


Author: ksmyth
Date: Mon Dec  5 13:24:37 2011
New Revision: 1729

Log:
Refactor MUTest into Mixin

Modified:
   trunk/Tests/GPyUnit/test_registry.py
   trunk/Tests/GPyUnit/util/__init__.py

Modified: trunk/Tests/GPyUnit/test_registry.py
==============================================================================
--- trunk/Tests/GPyUnit/test_registry.py	Mon Dec  5 13:24:24 2011	(r1728)
+++ trunk/Tests/GPyUnit/test_registry.py	Mon Dec  5 13:24:37 2011	(r1729)
@@ -16,7 +16,6 @@
     def tearDown(self):
         if not self.project is None:
             self.project.Close(True)
-    
 
     @property
     def connstr(self):
@@ -173,23 +172,10 @@
             self.project.BeginTransactionInNewTerr()
             self.project.RootFolder.ChildFolders
 
-class TestMURegistry(TestRegistry):
+import GPyUnit.util
+class TestMURegistry(GPyUnit.util.MUTestMixin, TestRegistry):
     def __init__(self, name, **kwds):
         super(TestMURegistry, self).__init__(name, **kwds)
-        import os.path
-        self.mgxdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "TestMURegistry"))
-
-    def setUp(self):
-        import os.path
-        if os.path.isdir(self.mgxdir):
-            import shutil
-            assert len(self.mgxdir) > 10 # sanity check
-            shutil.rmtree(self.mgxdir)
-    
-    @property
-    def connstr(self):
-        return "MGX=\"" + self.mgxdir + "\""
-
 
 if __name__ == "__main__":
     unittest.main()

Modified: trunk/Tests/GPyUnit/util/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/util/__init__.py	Mon Dec  5 13:24:24 2011	(r1728)
+++ trunk/Tests/GPyUnit/util/__init__.py	Mon Dec  5 13:24:37 2011	(r1729)
@@ -1,4 +1,6 @@
 
+import unittest
+
 class disable_early_binding(object):
 	def __enter__(self):
 		import win32com.client.gencache
@@ -27,3 +29,21 @@
         xmpfile = predef[xmpfile]
     import gme
     gme.register_if_not_registered(xmpfile)
+
+class MUTestMixin(unittest.TestCase): # need to inherit from TestCase so __mro__ works, since TestCase.__init__ doesn't call super().__init__
+    def __init__(self, name, **kwds):
+        super(MUTestMixin, self).__init__(name, **kwds)
+        import os.path
+        self.mgxdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "MUTest"))
+
+    def setUp(self):
+        super(MUTestMixin, self).setUp()
+        import os.path
+        if os.path.isdir(self.mgxdir):
+            import shutil
+            assert len(self.mgxdir) > 10 # sanity check
+            shutil.rmtree(self.mgxdir)
+    
+    @property
+    def connstr(self):
+        return "MGX=\"" + self.mgxdir + "\""


More information about the gme-commit mailing list