# HG changeset patch # User Christophe de Vienne # Date 1422450180 -3600 # Node ID 2659f8529a43ecdf4d386c62a975e63c760bee93 # Parent 7e1c8fb9c4070d63c88925768376f92a0a9152f9 [devtools] Make PostgresTestDataBaseHandler multi-use friendly Dont init the pgdb twice on the same datadir - If two test case with the same apphome use a Postgres configuration, the handler is initialised twice, so it has to check if the pgdb directory has already been initialized. - Work with the realpath of the pgdb In some cases, the self.config.apphome will resolve symbolic links, but not always. It can result in an attempt to start twice the pg server for the same directory, in the same test run... resulting in failure. Closes #4875827 diff -r 7e1c8fb9c407 -r 2659f8529a43 devtools/__init__.py --- a/devtools/__init__.py Mon Feb 02 12:07:10 2015 +0100 +++ b/devtools/__init__.py Wed Jan 28 14:03:00 2015 +0100 @@ -33,7 +33,7 @@ import getpass from hashlib import sha1 # pylint: disable=E0611 from datetime import timedelta -from os.path import (abspath, join, exists, split, isabs, isdir) +from os.path import (abspath, realpath, join, exists, split, isabs, isdir) from functools import partial from logilab.common.date import strptime @@ -549,7 +549,9 @@ def __init__(self, *args, **kwargs): super(PostgresTestDataBaseHandler, self).__init__(*args, **kwargs) - datadir = join(self.config.apphome, 'pgdb') + datadir = realpath(join(self.config.apphome, 'pgdb')) + if datadir in self.__CTL: + return if not exists(datadir): try: subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C'])