MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_pickling

Method test_pickling

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

Source from the content-addressed store, hash-verified

4458 self.assertEqual(hash(t1), hash(t2))
4459
4460 def test_pickling(self):
4461 # Try one without a tzinfo.
4462 args = 20, 59, 16, 64**2
4463 orig = self.theclass(*args)
4464 for pickler, unpickler, proto in pickle_choices:
4465 green = pickler.dumps(orig, proto)
4466 derived = unpickler.loads(green)
4467 self.assertEqual(orig, derived)
4468 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4469
4470 # Try one with a tzinfo.
4471 tinfo = PicklableFixedOffset(-300, 'cookie')
4472 orig = self.theclass(5, 6, 7, tzinfo=tinfo)
4473 for pickler, unpickler, proto in pickle_choices:
4474 green = pickler.dumps(orig, proto)
4475 derived = unpickler.loads(green)
4476 self.assertEqual(orig, derived)
4477 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
4478 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
4479 self.assertEqual(derived.tzname(), 'cookie')
4480 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4481
4482 def test_compat_unpickle(self):
4483 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