[FIX] Test for ir_sequence:

This test was depending on the error string returned by postgresql.
As these strings are localized, the test was failing on systems 
where posgresql locale was not set to 'en_US'.

In this new version, we now check the error code returned by postgresql 
(which is, obviously, platform independent)

bzr revid: rim@openerp.com-20140306110356-72mgz3korkq3rkde
This commit is contained in:
Richard Mathot (OpenERP) 2014-03-06 12:03:56 +01:00
parent e231045095
commit 3c65ffc29f
1 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@
# OPENERP_DATABASE=yy PYTHONPATH=../:. unit2 test_ir_sequence
# This assume an existing database.
import psycopg2
import psycopg2.errorcodes
import unittest2
import openerp
@ -111,11 +112,11 @@ class test_ir_sequence_no_gap(unittest2.TestCase):
cr0 = cursor()
cr1 = cursor()
cr1._default_log_exceptions = False # Prevent logging a traceback
msg_re = '^could not obtain lock on row in relation "ir_sequence"$'
with self.assertRaisesRegexp(psycopg2.OperationalError, msg_re):
with self.assertRaises(psycopg2.OperationalError) as e:
n0 = registry('ir.sequence').next_by_code(cr0, ADMIN_USER_ID, 'test_sequence_type_2', {})
assert n0
n1 = registry('ir.sequence').next_by_code(cr1, ADMIN_USER_ID, 'test_sequence_type_2', {})
assert e.exception.pgcode == psycopg2.errorcodes.LOCK_NOT_AVAILABLE
cr0.close()
cr1.close()