unittest2 fix: can't skip test in setUp, but it's fine in setUpClass stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 11 Jan 2011 15:23:29 +0100
branchstable
changeset 6804 4262d0d6abcb
parent 6803 691dac4c6a05
child 6805 d0d7345581d4
unittest2 fix: can't skip test in setUp, but it's fine in setUpClass
devtools/repotest.py
--- a/devtools/repotest.py	Tue Jan 11 12:45:30 2011 +0100
+++ b/devtools/repotest.py	Tue Jan 11 15:23:29 2011 +0100
@@ -149,6 +149,15 @@
 class RQLGeneratorTC(TestCase):
     schema = backend = None # set this in concret test
 
+
+    @classmethod
+    def setUpClass(cls):
+        if cls.backend is not None:
+            try:
+                cls.dbhelper = get_db_helper(cls.backend)
+            except ImportError, ex:
+                cls.skipTest(str(ex))
+
     def setUp(self):
         self.repo = FakeRepo(self.schema)
         self.repo.system_source = mock_object(dbdriver=self.backend)
@@ -159,11 +168,7 @@
         ExecutionPlan._check_permissions = _dummy_check_permissions
         rqlannotation._select_principal = _select_principal
         if self.backend is not None:
-            try:
-                dbhelper = get_db_helper(self.backend)
-            except ImportError, ex:
-                self.skipTest(str(ex))
-            self.o = SQLGenerator(self.schema, dbhelper)
+            self.o = SQLGenerator(self.schema, self.dbhelper)
 
     def tearDown(self):
         ExecutionPlan._check_permissions = _orig_check_permissions