test/unittest_rset.py
changeset 10602 4845012cfc8e
parent 10600 180aa08cad48
child 10603 65ad6980976e
equal deleted inserted replaced
10601:73c1c9cf6bda 10602:4845012cfc8e
    17 # You should have received a copy of the GNU Lesser General Public License along
    17 # You should have received a copy of the GNU Lesser General Public License along
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    19 """unit tests for module cubicweb.utils"""
    19 """unit tests for module cubicweb.utils"""
    20 
    20 
    21 from urlparse import urlsplit
    21 from urlparse import urlsplit
    22 import pickle
    22 
       
    23 from six.moves import cPickle as pickle
    23 
    24 
    24 from rql import parse
    25 from rql import parse
    25 
    26 
    26 from logilab.common.testlib import TestCase, unittest_main, mock_object
    27 from logilab.common.testlib import TestCase, unittest_main, mock_object
    27 
    28 
    98             params2 = dict(pair.split('=') for pair in info1[3].split('&'))
    99             params2 = dict(pair.split('=') for pair in info1[3].split('&'))
    99             self.assertDictEqual(params1, params2)
   100             self.assertDictEqual(params1, params2)
   100 
   101 
   101     def test_pickle(self):
   102     def test_pickle(self):
   102         del self.rset.req
   103         del self.rset.req
   103         self.assertEqual(len(pickle.dumps(self.rset)), 376)
   104         # 373 for python 2.7's cPickle
       
   105         # 376 for the old python pickle implementation
       
   106         self.assertIn(len(pickle.dumps(self.rset)), (373, 376))
   104 
   107 
   105     def test_build_url(self):
   108     def test_build_url(self):
   106         with self.admin_access.web_request() as req:
   109         with self.admin_access.web_request() as req:
   107             baseurl = req.base_url()
   110             baseurl = req.base_url()
   108             self.compare_urls(req.build_url('view', vid='foo', rql='yo'),
   111             self.compare_urls(req.build_url('view', vid='foo', rql='yo'),