Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e28209f2
Commit
e28209f2
authored
Nov 16, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9051: Added tests for pickling and copying the timezone objects.
parent
a0c9caad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
Lib/test/datetimetester.py
Lib/test/datetimetester.py
+28
-1
No files found.
Lib/test/datetimetester.py
View file @
e28209f2
...
...
@@ -3,6 +3,7 @@
See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
"""
import
copy
import
sys
import
pickle
import
random
...
...
@@ -223,7 +224,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
)
...
...
@@ -310,6 +310,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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment