diff options
Diffstat (limited to 'tests/test_couch.py')
-rw-r--r-- | tests/test_couch.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/test_couch.py b/tests/test_couch.py index 02399e4c..3482b035 100644 --- a/tests/test_couch.py +++ b/tests/test_couch.py @@ -27,6 +27,8 @@ import time import unittest +# from: https://github.com/smcq/paisley/blob/master/paisley/test/util.py +# TODO: include license of above project. class CouchDBWrapper(object): """ Wrapper for external CouchDB instance which is started and stopped for @@ -42,6 +44,7 @@ class CouchDBWrapper(object): conf = handle.read() % { 'tempdir': self.tempdir, } + handle.close() confPath = os.path.join(self.tempdir, 'test.ini') handle = open(confPath, 'w') @@ -51,10 +54,11 @@ class CouchDBWrapper(object): # create the dirs from the template os.mkdir(os.path.join(self.tempdir, 'lib')) os.mkdir(os.path.join(self.tempdir, 'log')) - argus = ['couchdb', '-n' '-a', confPath] - null = open('/dev/null', 'w') + args = ['couchdb', '-n' '-a', confPath] + #null = open('/dev/null', 'w') self.process = subprocess.Popen( - argus, env=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + args, env=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + close_fds=True) # find port logPath = os.path.join(self.tempdir, 'log', 'couch.log') while not os.path.exists(logPath): @@ -75,6 +79,7 @@ stderr: handle = open(logPath) line = handle.read() + handle.close() m = PORT_RE.search(line) if not m: self.stop() @@ -83,7 +88,7 @@ stderr: def stop(self): self.process.terminate() - + self.process.wait() os.system("rm -rf %s" % self.tempdir) |