[tests] Stop counting pickle bytes in ResultSet tests
authorRémi Cardona <remi.cardona@logilab.fr>
Mon, 21 Sep 2015 18:04:22 +0200
changeset 10722 1d0b5aef7523
parent 10721 e9abbaa835f5
child 10723 c5bedfdd1b22
[tests] Stop counting pickle bytes in ResultSet tests Between python 2's pickle and cPickle implementations, the various protocol versions added in python 3, the length of the pickled string is completely unpredictable. Instead, do a simple round trip and test a few attributes.
test/unittest_rset.py
--- a/test/unittest_rset.py	Mon Sep 21 17:54:15 2015 +0200
+++ b/test/unittest_rset.py	Mon Sep 21 18:04:22 2015 +0200
@@ -101,9 +101,11 @@
 
     def test_pickle(self):
         del self.rset.req
-        # 373 for python 2.7's cPickle
-        # 376 for the old python pickle implementation
-        self.assertIn(len(pickle.dumps(self.rset)), (373, 376))
+        rs2 = pickle.loads(pickle.dumps(self.rset))
+        self.assertEqual(self.rset.rows, rs2.rows)
+        self.assertEqual(self.rset.rowcount, rs2.rowcount)
+        self.assertEqual(self.rset.rql, rs2.rql)
+        self.assertEqual(self.rset.description, rs2.description)
 
     def test_build_url(self):
         with self.admin_access.web_request() as req: