[FIX] test_db_cursor: explicitely close the cursor (without relying on __del__).
bzr revid: vmt@openerp.com-20121115123937-keq4eb2a3n85x0rv
This commit is contained in:
parent
08a2115754
commit
147fae832a
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue