-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for __add__ and __sub__ and basic timedelta math
- Loading branch information
1 parent
3b4ae2b
commit 9f5a8b4
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
t/output-comparison-python-interpreter/stdlib-datetime-timedelta-math.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from datetime import timedelta | ||
|
||
print(timedelta(1) + timedelta(2)) | ||
print(timedelta(2) - timedelta(1)) | ||
|
||
try: | ||
timedelta(1) + 'a' | ||
except TypeError: | ||
print "timedelta addition with invalid type raises TypeError, as expected." | ||
|
||
try: | ||
timedelta(1) - 'a' | ||
except TypeError: | ||
print "timedelta subtraction with invalid type raises TypeError, as expected." |