|
@@ -118,7 +118,19 @@ class Test0RpnModule(unittest.TestCase):
|
118
|
118
|
entropy = 1-sum([(n/all_count)**2
|
119
|
119
|
for _, n in counters.items()])
|
120
|
120
|
self.assertGreater(entropy, 1-(1/all_ops), "Low entropy !")
|
121
|
|
-
|
|
121
|
+
|
|
122
|
+ def test_pickle_state(self):
|
|
123
|
+ """ Testing pickling/unpickling """
|
|
124
|
+ e = pyrpn.RPNExpr(pyrpn.random_expr(2), 2)
|
|
125
|
+
|
|
126
|
+ e2 = pickle.loads(pickle.dumps(e))
|
|
127
|
+
|
|
128
|
+ self.assertEqual(e.__getstate__(), e2.__getstate__())
|
|
129
|
+
|
|
130
|
+ e3 = pickle.loads(pickle.dumps(e2))
|
|
131
|
+
|
|
132
|
+ self.assertEqual(e.__getstate__(), e3.__getstate__())
|
|
133
|
+ self.assertEqual(e2.__getstate__(), e3.__getstate__())
|
122
|
134
|
|
123
|
135
|
if __name__ == '__main__':
|
124
|
136
|
unittest.main()
|