Skip to content
Snippets Groups Projects
Commit cc9113f8 authored by dufresnedavid's avatar dufresnedavid Committed by Xavier Morel
Browse files

[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).
parent acf22b7b
Branches
Tags
No related merge requests found
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment