Assert that an object can be pickled and unpickled. This assertion assumes that the desired behavior is that the unpickled object is the same as the original, when singleton=True.
(self, obj, singleton=False, asfile=False,
dump_kwargs=None, load_kwargs=None)
| 148 | return nobj |
| 149 | |
| 150 | def assertPicklable(self, obj, singleton=False, asfile=False, |
| 151 | dump_kwargs=None, load_kwargs=None): |
| 152 | """ |
| 153 | Assert that an object can be pickled and unpickled. This assertion |
| 154 | assumes that the desired behavior is that the unpickled object is the same |
| 155 | as the original, when singleton=True. |
| 156 | """ |
| 157 | get_nobj = self._get_nobj_file if asfile else self._get_nobj_bytes |
| 158 | dump_kwargs = dump_kwargs or {} |
| 159 | load_kwargs = load_kwargs or {} |
| 160 | |
| 161 | nobj = get_nobj(obj, dump_kwargs, load_kwargs) |
| 162 | if singleton: |
| 163 | self.assertIs(obj, nobj) |
| 164 | else: |
| 165 | self.assertIsNot(obj, nobj) |
| 166 | self.assertEqual(obj, nobj) |
| 167 | |
| 168 | |
| 169 | class TZContextBase: |
no outgoing calls