From bca2737f6b0a72a7411d8a2b88f9611a5e511153 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 13 Jan 2016 13:36:17 +0100 Subject: [PATCH] [PORT][9.0] Adapt tests to take new constraint raising IntegrityError --- partner_firstname/tests/test_empty.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/partner_firstname/tests/test_empty.py b/partner_firstname/tests/test_empty.py index a436a19cd..1bbdf74dd 100644 --- a/partner_firstname/tests/test_empty.py +++ b/partner_firstname/tests/test_empty.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- # © 2014-2015 Grupo ESOC +# © 2016 Yannick Vaucher (Camptocamp) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). """Test situations where names are empty. To have more accurate results, remove the ``mail`` module before testing. """ +import psycopg2 from openerp.tests.common import TransactionCase from .base import MailInstalled @@ -19,8 +21,13 @@ class CompanyCase(TransactionCase): def tearDown(self): try: data = {"name": self.name} - with self.assertRaises(ex.EmptyNamesError): - self.env[self.model].with_context(**self.context).create(data) + model = self.env[self.model].with_context(**self.context) + if self.name is False: + with self.assertRaises(psycopg2.IntegrityError): + model.create(data) + else: + with self.assertRaises(ex.EmptyNamesError): + model.create(data) finally: super(CompanyCase, self).tearDown()