From 0c42a607ece06b6295ba9d2c71bd8862e4e253ae Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 5 Feb 2019 18:38:19 +0100 Subject: [PATCH] [FIX] base: correct TestCursor test to explicitly close the cursor --- odoo/addons/base/tests/test_db_cursor.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/tests/test_db_cursor.py b/odoo/addons/base/tests/test_db_cursor.py index 1e945bf975c..839bcff6f89 100644 --- a/odoo/addons/base/tests/test_db_cursor.py +++ b/odoo/addons/base/tests/test_db_cursor.py @@ -33,13 +33,22 @@ class TestExecute(unittest.TestCase): class TestTestCursor(common.TransactionCase): + @classmethod + def setUpClass(cls): + super(TestTestCursor, cls).setUpClass() + r = registry() + r.enter_test_mode(r.cursor()) + + @classmethod + def tearDownClass(cls): + r = registry() + r.test_cr.close() + r.leave_test_mode() + super(TestTestCursor, cls).tearDownClass() def setUp(self): super(TestTestCursor, self).setUp() - self.registry.enter_test_mode(self.cr) - self.addCleanup(self.registry.leave_test_mode) self.record = self.env['res.partner'].create({'name': 'Foo'}) - self.cr = self.cursor() def write(self, record, value): record.ref = value