Changed the tests to stop using __setstate__(). __setstate__() no
longer needs to be public, and shoudn't be public because all datetime objects are immutable. The Python implementation has changed accordingly, but still need to change the C implementation.
This commit is contained in:
parent
08a1d9cafc
commit
96940c971c
|
@ -280,9 +280,6 @@ class TestTimeDelta(unittest.TestCase):
|
|||
orig = timedelta(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(args, state)
|
||||
derived = timedelta()
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -837,9 +834,6 @@ class TestDate(unittest.TestCase):
|
|||
orig = self.theclass(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(state, ('\x00\x06\x07\x17',), self.theclass)
|
||||
derived = self.theclass(1, 1, 1)
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -1194,9 +1188,6 @@ class TestDateTime(TestDate):
|
|||
orig = self.theclass(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(state, ('\x00\x06\x07\x17\x14\x3b\x01\x00\x10\x00',))
|
||||
derived = self.theclass(1, 1, 1)
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -1578,9 +1569,6 @@ class TestTime(unittest.TestCase):
|
|||
orig = self.theclass(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(state, ('\x14\x3b\x10\x00\x10\x00',))
|
||||
derived = self.theclass()
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -1891,9 +1879,6 @@ class TestTimeTZ(TestTime, TZInfoBase):
|
|||
orig = self.theclass(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(state, ('\x14\x3b\x10\x00\x10\x00',))
|
||||
derived = self.theclass()
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -1902,20 +1887,11 @@ class TestTimeTZ(TestTime, TZInfoBase):
|
|||
# Try one with a tzinfo.
|
||||
tinfo = PicklableFixedOffset(-300, 'cookie')
|
||||
orig = self.theclass(5, 6, 7, tzinfo=tinfo)
|
||||
state = orig.__getstate__()
|
||||
derived = self.theclass(tzinfo=FixedOffset(0, "UTC", 0))
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
self.failUnless(isinstance(derived.tzinfo, PicklableFixedOffset))
|
||||
self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
|
||||
self.assertEqual(derived.tzname(), 'cookie')
|
||||
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
self.assertEqual(orig, derived)
|
||||
self.failUnless(isinstance(derived.tzinfo,
|
||||
PicklableFixedOffset))
|
||||
self.failUnless(isinstance(derived.tzinfo, PicklableFixedOffset))
|
||||
self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
|
||||
self.assertEqual(derived.tzname(), 'cookie')
|
||||
|
||||
|
@ -2106,9 +2082,6 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase):
|
|||
orig = self.theclass(*args)
|
||||
state = orig.__getstate__()
|
||||
self.assertEqual(state, ('\x00\x06\x07\x17\x14\x3b\x01\x00\x10\x00',))
|
||||
derived = self.theclass(1, 1, 1)
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
@ -2117,14 +2090,7 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase):
|
|||
# Try one with a tzinfo.
|
||||
tinfo = PicklableFixedOffset(-300, 'cookie')
|
||||
orig = self.theclass(*args, **{'tzinfo': tinfo})
|
||||
state = orig.__getstate__()
|
||||
derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
|
||||
derived.__setstate__(state)
|
||||
self.assertEqual(orig, derived)
|
||||
self.failUnless(isinstance(derived.tzinfo, PicklableFixedOffset))
|
||||
self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
|
||||
self.assertEqual(derived.tzname(), 'cookie')
|
||||
|
||||
for pickler, unpickler, proto in pickle_choices:
|
||||
green = pickler.dumps(orig, proto)
|
||||
derived = unpickler.loads(green)
|
||||
|
|
Loading…
Reference in New Issue