summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-16 09:19:31 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-16 09:19:31 (GMT)
commitf242aebbd31738e9ffce59d1ce557ec085e1c1c7 (patch)
tree1599e99f4522c4c0768085269c4db4c0989424c7 /Lib/test/datetimetester.py
parenta4d33b34286e30819b36cc9e6d357d16eca813e4 (diff)
parente28209f251cfee80ce36ee3b7990f4baacf2e01c (diff)
downloadcpython-f242aebbd31738e9ffce59d1ce557ec085e1c1c7.zip
cpython-f242aebbd31738e9ffce59d1ce557ec085e1c1c7.tar.gz
cpython-f242aebbd31738e9ffce59d1ce557ec085e1c1c7.tar.bz2
Issue #9051: Added tests for pickling and copying the timezone objects.
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 63c3ae8..6365c60 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -3,6 +3,7 @@
See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
"""
+import copy
import decimal
import sys
import pickle
@@ -235,7 +236,6 @@ class TestTimeZone(unittest.TestCase):
tzrep = repr(tz)
self.assertEqual(tz, eval(tzrep))
-
def test_class_members(self):
limit = timedelta(hours=23, minutes=59)
self.assertEqual(timezone.utc.utcoffset(None), ZERO)
@@ -322,6 +322,33 @@ class TestTimeZone(unittest.TestCase):
self.assertEqual(tz.dst(t),
t.replace(tzinfo=tz).dst())
+ def test_pickle(self):
+ for tz in self.ACDT, self.EST, timezone.min, timezone.max:
+ for pickler, unpickler, proto in pickle_choices:
+ tz_copy = unpickler.loads(pickler.dumps(tz, proto))
+ self.assertEqual(tz_copy, tz)
+ tz = timezone.utc
+ for pickler, unpickler, proto in pickle_choices:
+ tz_copy = unpickler.loads(pickler.dumps(tz, proto))
+ self.assertIs(tz_copy, tz)
+
+ def test_copy(self):
+ for tz in self.ACDT, self.EST, timezone.min, timezone.max:
+ tz_copy = copy.copy(tz)
+ self.assertEqual(tz_copy, tz)
+ tz = timezone.utc
+ tz_copy = copy.copy(tz)
+ self.assertIs(tz_copy, tz)
+
+ def test_deepcopy(self):
+ for tz in self.ACDT, self.EST, timezone.min, timezone.max:
+ tz_copy = copy.deepcopy(tz)
+ self.assertEqual(tz_copy, tz)
+ tz = timezone.utc
+ tz_copy = copy.deepcopy(tz)
+ self.assertIs(tz_copy, tz)
+
+
#############################################################################
# Base class for testing a particular aspect of timedelta, time, date and
# datetime comparisons.