[IMP] Prevent unclosed cursor during tests
If an error happens in an overload of setUp, the already-open cursor is likely not to get properly released before the next test, deadlocking the db, because tearDown only runs if setUp has succesfully completed. Cleanups were added specifically to run every time, after tearDown has (potentially) been executed. closes #8327 Note: cleanups run in LIFO order (as they should).
This commit is contained in:
parent
acf22b7bc8
commit
cc9113f818
|
@ -94,9 +94,10 @@ class TransactionCase(BaseCase):
|
|||
TransactionCase.cr = self.cursor()
|
||||
TransactionCase.uid = openerp.SUPERUSER_ID
|
||||
|
||||
def tearDown(self):
|
||||
self.cr.rollback()
|
||||
self.cr.close()
|
||||
@self.addCleanup
|
||||
def close_cursor():
|
||||
self.cr.rollback()
|
||||
self.cr.close()
|
||||
|
||||
|
||||
class SingleTransactionCase(BaseCase):
|
||||
|
|
Loading…
Reference in New Issue