MCPcopy Index your code
hub / github.com/python/cpython / test_pickling

Method test_pickling

Lib/test/datetimetester.py:4642–4662  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4640 self.assertEqual(hash(t1), hash(t2))
4641
4642 def test_pickling(self):
4643 # Try one without a tzinfo.
4644 args = 20, 59, 16, 64**2
4645 orig = self.theclass(*args)
4646 for pickler, unpickler, proto in pickle_choices:
4647 green = pickler.dumps(orig, proto)
4648 derived = unpickler.loads(green)
4649 self.assertEqual(orig, derived)
4650 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4651
4652 # Try one with a tzinfo.
4653 tinfo = PicklableFixedOffset(-300, 'cookie')
4654 orig = self.theclass(5, 6, 7, tzinfo=tinfo)
4655 for pickler, unpickler, proto in pickle_choices:
4656 green = pickler.dumps(orig, proto)
4657 derived = unpickler.loads(green)
4658 self.assertEqual(orig, derived)
4659 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
4660 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
4661 self.assertEqual(derived.tzname(), 'cookie')
4662 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4663
4664 def test_compat_unpickle(self):
4665 tests = [

Callers

nothing calls this directly

Calls 10

timedeltaClass · 0.90
assertIsInstanceMethod · 0.80
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45
__reduce__Method · 0.45
__reduce_ex__Method · 0.45
utcoffsetMethod · 0.45
tznameMethod · 0.45

Tested by

no test coverage detected