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
1b402925
Commit
1b402925
authored
Jun 22, 2010
by
Alexander Belopolsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more test cases
parent
0aae6dc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
Lib/test/test_datetime.py
Lib/test/test_datetime.py
+25
-0
No files found.
Lib/test/test_datetime.py
View file @
1b402925
...
...
@@ -301,6 +301,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
c
=
td
(
0
,
0
,
1000
)
# One millisecond
eq
(
a
+
b
+
c
,
td
(
7
,
60
,
1000
))
eq
(
a
-
b
,
td
(
6
,
24
*
3600
-
60
))
eq
(
b
.
__rsub__
(
a
),
td
(
6
,
24
*
3600
-
60
))
eq
(
-
a
,
td
(
-
7
))
eq
(
+
a
,
td
(
7
))
eq
(
-
b
,
td
(
-
1
,
24
*
3600
-
60
))
...
...
@@ -378,6 +379,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
self
.
assertRaises
(
ZeroDivisionError
,
lambda
:
a
//
zero
)
self
.
assertRaises
(
ZeroDivisionError
,
lambda
:
a
/
zero
)
self
.
assertRaises
(
ZeroDivisionError
,
lambda
:
a
/
0.0
)
self
.
assertRaises
(
TypeError
,
lambda
:
a
/
''
)
@
requires_IEEE_754
def
test_disallowed_special
(
self
):
...
...
@@ -503,10 +505,20 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
microseconds
=
999999
)),
"999999999 days, 23:59:59.999999"
)
def
test_repr
(
self
):
name
=
'datetime.'
+
self
.
theclass
.
__name__
self
.
assertEqual
(
repr
(
self
.
theclass
(
1
)),
"%s(1)"
%
name
)
self
.
assertEqual
(
repr
(
self
.
theclass
(
10
,
2
)),
"%s(10, 2)"
%
name
)
self
.
assertEqual
(
repr
(
self
.
theclass
(
-
10
,
2
,
400000
)),
"%s(-10, 2, 400000)"
%
name
)
def
test_roundtrip
(
self
):
for
td
in
(
timedelta
(
days
=
999999999
,
hours
=
23
,
minutes
=
59
,
seconds
=
59
,
microseconds
=
999999
),
timedelta
(
days
=-
999999999
),
timedelta
(
days
=-
999999999
,
seconds
=
1
),
timedelta
(
days
=
1
,
seconds
=
2
,
microseconds
=
3
)):
# Verify td -> string -> td identity.
...
...
@@ -3480,6 +3492,19 @@ class TestTimezoneConversions(unittest.TestCase):
def
dst
(
self
,
dt
):
return
None
self
.
assertRaises
(
ValueError
,
now
.
astimezone
,
notok
())
# Sometimes blow up. In the following, tzinfo.dst()
# implementation may return None or not Nonedepending on
# whether DST is assumed to be in effect. In this situation,
# a ValueError should be raised by astimezone().
class
tricky_notok
(
ok
):
def
dst
(
self
,
dt
):
if
dt
.
year
==
2000
:
return
None
else
:
return
10
*
HOUR
dt
=
self
.
theclass
(
2001
,
1
,
1
).
replace
(
tzinfo
=
utc_real
)
self
.
assertRaises
(
ValueError
,
dt
.
astimezone
,
tricky_notok
())
def
test_fromutc
(
self
):
self
.
assertRaises
(
TypeError
,
Eastern
.
fromutc
)
# not enough args
now
=
datetime
.
utcnow
().
replace
(
tzinfo
=
utc_real
)
...
...
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