devtools/testlib.py
changeset 10639 1ed205146ee2
parent 10638 243e96db0004
child 10646 45671fb330f5
child 10792 daef7ce08fea
--- a/devtools/testlib.py	Thu Oct 08 18:09:10 2015 +0200
+++ b/devtools/testlib.py	Thu Oct 08 18:24:09 2015 +0200
@@ -719,12 +719,14 @@
                 origperms = erschema.permissions[action]
                 erschema.set_action_permissions(action, actionperms)
                 torestore.append([erschema, action, origperms])
-        yield
-        for erschema, action, permissions in torestore:
-            if action is None:
-                erschema.permissions = permissions
-            else:
-                erschema.set_action_permissions(action, permissions)
+        try:
+            yield
+        finally:
+            for erschema, action, permissions in torestore:
+                if action is None:
+                    erschema.permissions = permissions
+                else:
+                    erschema.set_action_permissions(action, permissions)
 
     def assertModificationDateGreater(self, entity, olddate):
         entity.cw_attr_cache.pop('modification_date', None)