[PATCH 1 of 2 hglib] tests: hook into hgclient.open for closing open cmdservers
Idan Kamara
idankk86 at gmail.com
Tue Jan 17 22:43:31 UTC 2012
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1326839964 -7200
# Node ID d1a42c1d0b618eb401fd5fdfe071512e3c00ef7c
# Parent dd63d69a5ebf166be56796e29dd2e4560154c077
tests: hook into hgclient.open for closing open cmdservers
So we ensure proper cleanup and cover all top level functions.
diff --git a/tests/common.py b/tests/common.py
--- a/tests/common.py
+++ b/tests/common.py
@@ -2,13 +2,13 @@
import unittest
import hglib
+from hglib import client
def resultappender(list):
def decorator(f):
def decorated(*args, **kwargs):
- result = f(*args, **kwargs)
- list.append(result)
- return result
+ list.append(args[0])
+ return f(*args, **kwargs)
return decorated
return decorator
@@ -18,8 +18,9 @@
os.path.join(os.environ["HGTMP"], self.__class__.__name__)
self.clients = []
- self._oldopen = hglib.open
- hglib.open = resultappender(self.clients)(hglib.open)
+ self._oldopen = hglib.client.hgclient.open
+ # hglib.open = resultappender(self.clients)(hglib.open)
+ hglib.client.hgclient.open = resultappender(self.clients)(hglib.client.hgclient.open)
os.mkdir(self._testtmp)
os.chdir(self._testtmp)
@@ -30,7 +31,7 @@
def tearDown(self):
# on Windows we cannot rmtree before closing all instances because of used
# files
- hglib.open = self._oldopen
+ hglib.client.hgclient.open = self._oldopen
for client in self.clients:
if client.server is not None:
client.close()
More information about the Mercurial-devel
mailing list