Reviewers: ,


Please review this at http://codereview.tryton.org/557003/

Affected files:
  M trytond/tests/test_modelsql.py


Index: trytond/tests/test_modelsql.py
===================================================================
--- a/trytond/tests/test_modelsql.py
+++ b/trytond/tests/test_modelsql.py
@@ -5,6 +5,7 @@

 import unittest

+from trytond.backend import DatabaseOperationalError
 from trytond.config import CONFIG
 from trytond.exceptions import UserError
 from trytond.transaction import Transaction
@@ -32,14 +33,18 @@
             'desc': '',
             'integer': 0,
             }
+        if CONFIG['db_type'] == 'postgresql':
+            err_class = UserError
+        else:
+            err_class = DatabaseOperationalError
         for key, value in fields.iteritems():
             with Transaction().start(DB_NAME, USER, context=CONTEXT):
                 try:
                     self.modelsql.create({key: value})
-                except UserError, err:
+                except err_class, err:
                     # message must not quote key
msg = "'%s' not missing but quoted in error: '%s'" % (key,
-                            err.message)
+                            err)
                     self.assertTrue(key not in err.message, msg)
                     continue
                 self.fail('UserError should be caught')


--
[email protected] mailing list

Reply via email to