[PATCH 4 of 5 saem_ref v2] Factor out setup/teardown of ccplugin tests

Denis Laxalde denis.laxalde at logilab.fr
Mon Jan 8 15:06:00 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1515418997 -3600
#      Mon Jan 08 14:43:17 2018 +0100
# Node ID 53cbebb6a3f7ef27bb61fa8e8c98a49a5c475ab4
# Parent  745664aaede05a0172e67cba9b639c9ae01b03e9
# EXP-Topic lcsv-skos-import
Factor out setup/teardown of ccplugin tests

We'll add another test case class that'd require similar setup in the
next changeset.

diff --git a/test/test_ccplugin.py b/test/test_ccplugin.py
--- a/test/test_ccplugin.py
+++ b/test/test_ccplugin.py
@@ -35,21 +35,27 @@ def setUpModule():
     testutils.startpgcluster(__file__)
 
 
-class ImportEacDataCommandTC(testlib.CubicWebTC):
+class CCPluginTC(testlib.CubicWebTC):
+
+    def setup_database(self):
+        super(CCPluginTC, self).setup_database()
+        self.orig_config_for = CubicWebConfiguration.config_for
+        CubicWebConfiguration.config_for = staticmethod(lambda appid: self.config)
+
+    def tearDown(self):
+        CubicWebConfiguration.config_for = self.orig_config_for
+        super(CCPluginTC, self).tearDown()
+
+
+class ImportEacDataCommandTC(CCPluginTC):
     configcls = PostgresApptestConfiguration
 
     def setup_database(self):
         super(ImportEacDataCommandTC, self).setup_database()
-        self.orig_config_for = CubicWebConfiguration.config_for
-        CubicWebConfiguration.config_for = staticmethod(lambda appid: self.config)
         with self.admin_access.client_cnx() as cnx:
             testutils.authority_with_naa(cnx)  # ensure we have a naming authority
             cnx.commit()
 
-    def tearDown(self):
-        CubicWebConfiguration.config_for = self.orig_config_for
-        super(ImportEacDataCommandTC, self).tearDown()
-
     def run_import_eac(self, *args):
         cmd = [self.appid, self.datapath('D33-100.xml')] + list(args)
         sys.stdout = output = BytesIO()



More information about the saem-devel mailing list