diff options
author | Lauro Neto <lauro.neto@openbossa.org> | 2010-07-20 15:32:58 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:07:21 -0300 |
commit | 24564c588380d5c9d55a1b4a12005996abbf60aa (patch) | |
tree | 8e4bc790a1d76551e578ad390bb6e3055b1367e6 /tests | |
parent | e22643e2abe1452f77b6d1ca2e27d2e44162feed (diff) |
Adding pickling test
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/samplebinding/copy_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
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() |