[test] use session commit/rollback to be consistent with the test
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 Sep 2012 16:18:13 +0200
changeset 8577 3f082de68802
parent 8576 c9c72ac10db3
child 8578 f6ea4ea63d57
[test] use session commit/rollback to be consistent with the test
entities/test/unittest_wfobjs.py
--- a/entities/test/unittest_wfobjs.py	Tue Oct 23 15:00:53 2012 +0200
+++ b/entities/test/unittest_wfobjs.py	Thu Sep 20 16:18:13 2012 +0200
@@ -622,23 +622,22 @@
         cnx.close()
 
     def test_transition_checking3(self):
-        cnx = self.login('stduser')
-        session = self.session
-        user = cnx.user(session)
-        iworkflowable = user.cw_adapt_to('IWorkflowable')
-        iworkflowable.fire_transition('deactivate')
-        cnx.commit()
-        session.set_cnxset()
-        with self.assertRaises(ValidationError) as cm:
+        with self.login('stduser') as cnx:
+            session = self.session
+            user = cnx.user(session)
+            iworkflowable = user.cw_adapt_to('IWorkflowable')
             iworkflowable.fire_transition('deactivate')
-        self.assertEqual(self._cleanup_msg(cm.exception.errors['by_transition-subject']),
-                                            u"transition isn't allowed from")
-        cnx.rollback()
-        session.set_cnxset()
-        # get back now
-        iworkflowable.fire_transition('activate')
-        cnx.commit()
-        cnx.close()
+            session.commit()
+            session.set_cnxset()
+            with self.assertRaises(ValidationError) as cm:
+                iworkflowable.fire_transition('deactivate')
+            self.assertEqual(self._cleanup_msg(cm.exception.errors['by_transition-subject']),
+                                                u"transition isn't allowed from")
+            session.rollback()
+            session.set_cnxset()
+            # get back now
+            iworkflowable.fire_transition('activate')
+            session.commit()
 
 
 if __name__ == '__main__':