[Python-checkins] cpython (merge 3.4 -> 3.5): Issue #9051: Added tests for pickling and copying the timezone objects.
serhiy.storchaka
python-checkins at python.org
Mon Nov 16 04:21:15 EST 2015
https://hg.python.org/cpython/rev/634905e9628d
changeset: 99154:634905e9628d
branch: 3.5
parent: 99151:3ae62099d70b
parent: 99153:e48da8f01316
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Nov 16 11:19:31 2015 +0200
summary:
Issue #9051: Added tests for pickling and copying the timezone objects.
files:
Lib/test/datetimetester.py | 29 +++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
--- 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 @@
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 @@
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.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list