test/unittest_dbapi.py
changeset 8367 fc59d2380c48
parent 8366 6599f69bb846
child 8544 3d049071957e
--- a/test/unittest_dbapi.py	Wed Apr 11 14:43:51 2012 +0200
+++ b/test/unittest_dbapi.py	Wed Apr 11 14:36:19 2012 +0200
@@ -84,16 +84,17 @@
             req.user.cw_adapt_to('IBreadCrumbs') # don't crash
 
     def test_call_service(self):
-        req = self.request()
         ServiceClass = self.vreg['services']['test_service'][0]
-        ret_value = req.cnx.call_service('test_service', msg='coucou')
-        self.assertEqual('coucou', ServiceClass.passed_here.pop())
-        self.assertEqual('babar', ret_value)
+        for _cw in (self.request(), self.session):
+            ret_value = _cw.call_service('test_service', msg='coucou')
+            self.assertEqual('coucou', ServiceClass.passed_here.pop())
+            self.assertEqual('babar', ret_value)
         with self.login('anon') as ctm:
-            with self.assertRaises(NoSelectableObject):
-                self.request().cnx.call_service('test_service', msg='toto')
-            self.rollback()
-            self.assertEqual([], ServiceClass.passed_here)
+            for _cw in (self.request(), self.session):
+                with self.assertRaises(NoSelectableObject):
+                    _cw.call_service('test_service', msg='toto')
+                self.rollback()
+                self.assertEqual([], ServiceClass.passed_here)
 
 
 if __name__ == '__main__':