diff --git a/openerp/tests/test_db_cursor.py b/openerp/tests/test_db_cursor.py index e9737547619..dba1cf47b64 100644 --- a/openerp/tests/test_db_cursor.py +++ b/openerp/tests/test_db_cursor.py @@ -9,8 +9,8 @@ import common DB = common.DB ADMIN_USER_ID = common.ADMIN_USER_ID -def cursor(): - return openerp.modules.registry.RegistryManager.get(DB).db.cursor() +def registry(): + return openerp.modules.registry.RegistryManager.get(DB) class test_cr_execute(unittest2.TestCase): @@ -21,12 +21,12 @@ class test_cr_execute(unittest2.TestCase): """ Try to use iterable but non-list or int params in query parameters. """ - cr = cursor() - with self.assertRaises(ValueError): - cr.execute("SELECT id FROM res_users WHERE login=%s", 'admin') - with self.assertRaises(ValueError): - cr.execute("SELECT id FROM res_users WHERE id=%s", 1) - with self.assertRaises(ValueError): - cr.execute("SELECT id FROM res_users WHERE id=%s", '1') + with registry().cursor(auto_commit=False) as cr: + with self.assertRaises(ValueError): + cr.execute("SELECT id FROM res_users WHERE login=%s", 'admin') + with self.assertRaises(ValueError): + cr.execute("SELECT id FROM res_users WHERE id=%s", 1) + with self.assertRaises(ValueError): + cr.execute("SELECT id FROM res_users WHERE id=%s", '1') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: