[Zope3-checkins] CVS: Zope3/src/datetime/tests - test_datetime.py:1.28

Tim Peters tim.one@comcast.net
Fri, 31 Jan 2003 17:01:07 -0500


Update of /cvs-repository/Zope3/src/datetime/tests
In directory cvs.zope.org:/tmp/cvs-serv16462/src/datetime/tests

Modified Files:
	test_datetime.py 
Log Message:
__setstate__() no longer needs to be public, and shoudn't be public
because all datetime objects are immutable.


=== Zope3/src/datetime/tests/test_datetime.py 1.27 => 1.28 ===
--- Zope3/src/datetime/tests/test_datetime.py:1.27	Thu Jan 30 21:24:34 2003
+++ Zope3/src/datetime/tests/test_datetime.py	Fri Jan 31 17:01:05 2003
@@ -278,13 +278,10 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
     def test_compare(self):
         t1 = timedelta(2, 3, 4)
@@ -835,13 +832,10 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
     def test_compare(self):
         t1 = self.theclass(2, 3, 4)
@@ -1192,13 +1186,10 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
     def test_more_compare(self):
         # The test_compare() inherited from TestDate covers the error cases.
@@ -1576,13 +1567,10 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
     def test_bool(self):
         cls = self.theclass
@@ -1889,33 +1877,21 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
         # 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.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
-                self.assertEqual(derived.tzname(), 'cookie')
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
+            self.failUnless(isinstance(derived.tzinfo, PicklableFixedOffset))
+            self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+            self.assertEqual(derived.tzname(), 'cookie')
 
     def test_more_bool(self):
         # Test cases with non-None tzinfo.
@@ -2104,33 +2080,23 @@
         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)
-                self.assertEqual(orig, derived)
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
 
         # 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)
-                self.assertEqual(orig, derived)
-                self.failUnless(isinstance(derived.tzinfo,
-                                PicklableFixedOffset))
-                self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
-                self.assertEqual(derived.tzname(), 'cookie')
+            green = pickler.dumps(orig, proto)
+            derived = unpickler.loads(green)
+            self.assertEqual(orig, derived)
+            self.failUnless(isinstance(derived.tzinfo,
+                            PicklableFixedOffset))
+            self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+            self.assertEqual(derived.tzname(), 'cookie')
 
     def test_extreme_hashes(self):
         # If an attempt is made to hash these via subtracting the offset