MCPcopy Create free account
hub / github.com/dateutil/dateutil / assertPicklable

Method assertPicklable

tests/_common.py:150–166  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
169class TZContextBase:

Callers 10

testPickleTzUTCMethod · 0.80
testPickleTzOffsetPosMethod · 0.80
testPickleTzOffsetNegMethod · 0.80
testPickleTzLocalMethod · 0.80
testPickleTzICalMethod · 0.80

Calls

no outgoing calls

Tested by 10

testPickleTzUTCMethod · 0.64
testPickleTzOffsetPosMethod · 0.64
testPickleTzOffsetNegMethod · 0.64
testPickleTzLocalMethod · 0.64
testPickleTzICalMethod · 0.64