From 3c65ffc29fae91af73e5341fbcc247824320a5d1 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Thu, 6 Mar 2014 12:03:56 +0100 Subject: [PATCH 1/2] [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() From 6f99891b82696f4d3eb059d3df8b17077011bab7 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Thu, 6 Mar 2014 12:20:53 +0100 Subject: [PATCH 2/2] [REF] Use assertEqual method instead of assert instruction bzr revid: rim@openerp.com-20140306112053-e0znv1g2378ghs46 --- openerp/tests/test_ir_sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/tests/test_ir_sequence.py b/openerp/tests/test_ir_sequence.py index 280eb9f8773..0b47560f3a4 100644 --- a/openerp/tests/test_ir_sequence.py +++ b/openerp/tests/test_ir_sequence.py @@ -116,7 +116,7 @@ class test_ir_sequence_no_gap(unittest2.TestCase): 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 + self.assertEqual(e.exception.pgcode, psycopg2.errorcodes.LOCK_NOT_AVAILABLE, msg="postgresql returned an incorrect errcode") cr0.close() cr1.close()