diff -r 865a3e522add -r 6efb7a7ae570 devtools/testlib.py --- a/devtools/testlib.py Wed Apr 07 11:57:37 2010 +0200 +++ b/devtools/testlib.py Wed Apr 07 14:42:12 2010 +0200 @@ -261,6 +261,12 @@ self.setup_database() self.commit() MAILBOX[:] = [] # reset mailbox + self._cnxs = [] + + def tearDown(self): + for cnx in self._cnxs: + if not cnx._closed: + cnx.close() def setup_database(self): """add your database setup code by overriding this method""" @@ -302,6 +308,7 @@ self.cnx = repo_connect(self.repo, unicode(login), cnxprops=ConnectionProperties('inmemory'), **kwargs) + self._cnxs.append(self.cnx) if login == self.vreg.config.anonymous_user()[0]: self.cnx.anonymous_connection = True return self.cnx @@ -310,6 +317,7 @@ if not self.cnx is self._orig_cnx: try: self.cnx.close() + self._cnxs.remove(self.cnx) except ProgrammingError: pass # already closed self.cnx = self._orig_cnx