From 24564c588380d5c9d55a1b4a12005996abbf60aa Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Tue, 20 Jul 2010 15:32:58 -0300 Subject: Adding pickling test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Luciano Wolf --- tests/samplebinding/copy_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/samplebinding/copy_test.py b/tests/samplebinding/copy_test.py index 3a0ff1876..e347182af 100644 --- a/tests/samplebinding/copy_test.py +++ b/tests/samplebinding/copy_test.py @@ -29,6 +29,12 @@ import copy import unittest +try: + import cPickle as pickle +except ImportError: + import pickle + + from sample import Point @@ -55,6 +61,21 @@ class DeepCopy(unittest.TestCase): self.assertEqual(point, new_point) +class PicklingTest(unittest.TestCase): + '''Support pickling''' + + def testSimple(self): + '''Simple pickling and unpickling''' + + point = Point(10.2, 43.5) + + data = pickle.dumps(point) + new_point = pickle.loads(data) + + self.assertEqual(point, new_point) + self.assert_(point is not new_point) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3