From 3c65ffc29fae91af73e5341fbcc247824320a5d1 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Thu, 6 Mar 2014 12:03:56 +0100 Subject: [PATCH] [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 --- openerp/tests/test_ir_sequence.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openerp/tests/test_ir_sequence.py b/openerp/tests/test_ir_sequence.py index cbb1a347038..280eb9f8773 100644 --- a/openerp/tests/test_ir_sequence.py +++ b/openerp/tests/test_ir_sequence.py @@ -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()