Assert that an object can be pickled and unpickled. This assertion assumes that the desired behavior is that the unpickled object compares equal to the original object, but is not the same object.
(self, obj, singleton=False, asfile=False,
dump_kwargs=None, load_kwargs=None)
| 30 | return nobj |
| 31 | |
| 32 | def assertPicklable(self, obj, singleton=False, asfile=False, |
| 33 | dump_kwargs=None, load_kwargs=None): |
| 34 | """ |
| 35 | Assert that an object can be pickled and unpickled. This assertion |
| 36 | assumes that the desired behavior is that the unpickled object compares |
| 37 | equal to the original object, but is not the same object. |
| 38 | """ |
| 39 | get_nobj = self._get_nobj_file if asfile else self._get_nobj_bytes |
| 40 | dump_kwargs = dump_kwargs or {} |
| 41 | load_kwargs = load_kwargs or {} |
| 42 | |
| 43 | nobj = get_nobj(obj, dump_kwargs, load_kwargs) |
| 44 | if not singleton: |
| 45 | self.assertIsNot(obj, nobj) |
| 46 | self.assertEqual(obj, nobj) |
| 47 | |
| 48 | |
| 49 | class TZContextBase(object): |
no outgoing calls