hooks/test/unittest_hooks.py
changeset 8594 001159e2e4f3
parent 8556 bbe0d6985e59
child 8694 d901c36bcfce
--- a/hooks/test/unittest_hooks.py	Fri Nov 09 15:27:40 2012 +0100
+++ b/hooks/test/unittest_hooks.py	Fri Nov 16 11:41:38 2012 +0100
@@ -165,14 +165,12 @@
                           self.execute, 'INSERT CWRType X: X name "in_group"')
 
     def test_validation_unique_constraint(self):
-        self.assertRaises(ValidationError,
-                          self.execute, 'INSERT CWUser X: X login "admin"')
-        try:
+        with self.assertRaises(ValidationError) as cm:
             self.execute('INSERT CWUser X: X login "admin"')
-        except ValidationError, ex:
-            ex.tr(unicode)
-            self.assertIsInstance(ex.entity, int)
-            self.assertEqual(ex.errors, {'login-subject': 'the value "admin" is already used, use another one'})
+        ex = cm.exception
+        ex.translate(unicode)
+        self.assertIsInstance(ex.entity, int)
+        self.assertEqual(ex.errors, {'login-subject': 'the value "admin" is already used, use another one'})
 
 
 if __name__ == '__main__':