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

Guido van Rossum guido@python.org
Fri, 7 Feb 2003 16:45:29 -0500


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

Modified Files:
	test_datetime.py 
Log Message:
Tres discovered a weird bug when a datetime is pickled, caused by the
shadowing of __year, __month, __day and the use of proxies.

Here's a quick fix and a quick unit test.  I don't quite understand
why this wasn't caught by the pickling unit tests.


=== Zope3/src/datetime/tests/test_datetime.py 1.32 => 1.33 ===
--- Zope3/src/datetime/tests/test_datetime.py:1.32	Fri Feb  7 16:06:39 2003
+++ Zope3/src/datetime/tests/test_datetime.py	Fri Feb  7 16:45:28 2003
@@ -1223,6 +1223,14 @@
             derived = unpickler.loads(green)
             self.assertEqual(orig, derived)
 
+    def test_more_pickling(self):
+        a = self.theclass(2003, 2, 7, 16, 48, 37, 444116)
+        s = pickle.dumps(a)
+        b = pickle.loads(s)
+        self.assertEqual(b.year, 2003)
+        self.assertEqual(b.month, 2)
+        self.assertEqual(b.day, 7)
+
     def test_more_compare(self):
         # The test_compare() inherited from TestDate covers the error cases.
         # We just want to test lexicographic ordering on the members datetime