[PATCH 04 of 11 saem_ref] Move custom startpgcluster out of the block concerning "global test config"

Denis Laxalde denis.laxalde at logilab.fr
Mon Feb 12 15:20:40 CET 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1518183415 -3600
#      Fri Feb 09 14:36:55 2018 +0100
# Node ID fb4b0e6037ab8c64cdc48c3322df1eb67b1651d3
# Parent  7572cbb74a1d8a57a804eb43a0651b45dd76dcd6
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r fb4b0e6037ab
# EXP-Topic ark/postgres-generated
Move custom startpgcluster out of the block concerning "global test config"

This code got introduced in 290cb15e914a along a change to avoid
(re)loading the registry for each test fixture though it's unrelated
(per commit message of that changeset).

diff --git a/test/testutils.py b/test/testutils.py
--- a/test/testutils.py
+++ b/test/testutils.py
@@ -167,6 +167,15 @@ class XmlTestMixin(object):
         xmlschema.assertValid(xml_data)
 
 
+def startpgcluster(pyfile):
+    """Let PostgreSQL cluster be started only once per process and stopped at exit.
+    """
+    if devtools.DEFAULT_PSQL_SOURCES['system']['db-host'] == 'REPLACEME':
+        devtools.startpgcluster(pyfile)
+        import atexit
+        atexit.register(devtools.stoppgcluster, pyfile)
+
+
 # speed up tests by using a global configuration ###################################################
 _CONFIGS = {}
 
@@ -193,13 +202,6 @@ def setUpClass(cls):
     cls.config = config
 
 
-def startpgcluster(pyfile):
-    if devtools.DEFAULT_PSQL_SOURCES['system']['db-host'] == 'REPLACEME':
-        devtools.startpgcluster(pyfile)
-        import atexit
-        atexit.register(devtools.stoppgcluster, pyfile)
-
-
 class _HCache(dict):
     """Original devtools handler cache prevent caching of several configurations, but that's
     what we're trying to achieve.



More information about the saem-devel mailing list