changeset 101:d1a42c1d0b61

tests: hook into hgclient.open for closing open cmdservers So we ensure proper cleanup and cover all top level functions.
author Idan Kamara <idankk86@gmail.com>
date Wed, 18 Jan 2012 00:39:24 +0200
parents dd63d69a5ebf
children cc2b7540fa2b
files tests/common.py
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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()