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

Method test_pickling

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

Source from the content-addressed store, hash-verified

4942 self.assertRaises(ValueError, lambda: t1 == t2)
4943
4944 def test_pickling(self):
4945 # Try one without a tzinfo.
4946 args = 6, 7, 23, 20, 59, 1, 64**2
4947 orig = self.theclass(*args)
4948 for pickler, unpickler, proto in pickle_choices:
4949 green = pickler.dumps(orig, proto)
4950 derived = unpickler.loads(green)
4951 self.assertEqual(orig, derived)
4952 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4953
4954 # Try one with a tzinfo.
4955 tinfo = PicklableFixedOffset(-300, 'cookie')
4956 orig = self.theclass(*args, **{'tzinfo': tinfo})
4957 derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
4958 for pickler, unpickler, proto in pickle_choices:
4959 green = pickler.dumps(orig, proto)
4960 derived = unpickler.loads(green)
4961 self.assertEqual(orig, derived)
4962 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
4963 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
4964 self.assertEqual(derived.tzname(), 'cookie')
4965 self.assertEqual(orig.__reduce__(), orig.__reduce_ex__(2))
4966
4967 def test_compat_unpickle(self):
4968 tests = [

Callers

nothing calls this directly

Calls 11

timedeltaClass · 0.90
assertIsInstanceMethod · 0.80
FixedOffsetClass · 0.70
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