# HG changeset patch # User Idan Kamara # 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 -r dd63d69a5ebf -r d1a42c1d0b61 tests/common.py --- a/tests/common.py Tue Jan 17 22:26:20 2012 +0200 +++ b/tests/common.py Wed Jan 18 00:39:24 2012 +0200 @@ -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()