cubicweb #3892565 PostgresApptestConfiguration works only when alone [validation pending]

A Testcase using PostgresApptestConfiguration will work only when alone in its file and this file is run separately.

I could not untangle the root problem but it has to do with the database name, among with other things, most notably the db cache mechanism.

I did find, however, an ugly hack that workarounds the problem.

First, avoid multi-lauch of pg_ctl on the same datadir:

diff -r 1141927b8494 devtools/
--- a/devtools/       Mon Apr 28 18:35:35 2014 +0200
+++ b/devtools/       Mon May 26 22:56:38 2014 +0200
@@ -547,6 +547,8 @@
         datadir = join(self.config.apphome, 'pgdb')
         if not exists(datadir):
             subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C'])
+        if datadir in self.__CTL:
+            return
         port = self.system_source['db-port']
         directory = self.system_source['db-host']
         env = os.environ.copy()

And then make a PostgresApptestConfiguration that sets different db-name for each instance:

# Workaround the fact that PG test cases play along badly with other TC if
# runned in the same process
class PostgresApptestConfiguration(

    dbnames = ('tmppgdb_%s' % i for i in xrange(99))

    def __init__(self, *args, **kw):
        super(devtools.PostgresApptestConfiguration, self).__init__(
            *args, **kw)
        self.default_sources = self.default_sources.copy()
        self.default_sources['system'] = self.default_sources['system'].copy()
        self.default_sources['system']['db-name'] =

Using the above class as a configcls makes it possible to run any number of TC at once.

done in3.21.0
load left0.000
closed by<not specified>