Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(148244)

Delta Between Two Patch Sets: Lib/test/datetimetester.py

Issue 17267: datetime.time support for '+' and 'now'
Left Patch Set: Created 6 years, 9 months ago
Right Patch Set: Created 6 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 """Test date/time type. 1 """Test date/time type.
2 2
3 See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases 3 See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
4 """ 4 """
5 5
6 import sys 6 import sys
7 import pickle 7 import pickle
8 import unittest 8 import unittest
9 9
10 from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod 10 from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 assert y is d2 2513 assert y is d2
2514 expected = 1 2514 expected = 1
2515 self.assertEqual(got, expected) 2515 self.assertEqual(got, expected)
2516 2516
2517 2517
2518 # Testing time objects with a non-None tzinfo. 2518 # Testing time objects with a non-None tzinfo.
2519 class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase): 2519 class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
2520 theclass = time 2520 theclass = time
2521 2521
2522 def test_computations(self): 2522 def test_computations(self):
2523 est = FixedOffset(-300, "EST") 2523 est = FixedOffset(-300, "EST", 1)
2524 utc = FixedOffset(0, "UTC") 2524 utc = FixedOffset(0, "UTC", -2)
2525 met = FixedOffset(60, "MET") 2525 met = FixedOffset(60, "MET", 3)
2526
2527 minute = timedelta(minutes=1)
2528 hour = timedelta(hours=1)
2529 week = timedelta(days=7)
2526 2530
2527 for tz in [est, utc, met]: 2531 for tz in [est, utc, met]:
2528 a = self.theclass(0, 0, 0, tzinfo=tz) 2532 a = self.theclass(0, 0, 0, tzinfo=tz)
2529 b = self.theclass(23, 59, tzinfo=tz) 2533 b = self.theclass(23, 59, tzinfo=tz)
2530
2531 minute = timedelta(minutes=1)
2532 hour = timedelta(hours=1)
2533 week = timedelta(days=7)
2534 self.assertEqual(a + minute, self.theclass(0, 1, 0, tzinfo=tz)) 2534 self.assertEqual(a + minute, self.theclass(0, 1, 0, tzinfo=tz))
2535 self.assertEqual(b + minute + minute, self.theclass(0, 1, tzinfo=tz) ) 2535 self.assertEqual(b + minute + minute, self.theclass(0, 1, tzinfo=tz) )
2536 self.assertEqual(b + minute, self.theclass(0, 0, tzinfo=tz)) 2536 self.assertEqual(b + minute, self.theclass(0, 0, tzinfo=tz))
2537 self.assertEqual(a + week, self.theclass(0, tzinfo=tz)) 2537 self.assertEqual(a + week, self.theclass(0, tzinfo=tz))
2538 self.assertEqual(a + week, self.theclass(0, tzinfo=tz)) 2538 self.assertEqual(a + week, self.theclass(0, tzinfo=tz))
2539 self.assertEqual(b + hour * 12, self.theclass(11, 59, tzinfo=tz)) 2539 self.assertEqual(b + hour * 12, self.theclass(11, 59, tzinfo=tz))
2540 2540
2541 c = self.theclass(0, 0, 0, tzinfo=est) 2541 c = self.theclass(0, 0, 0, tzinfo=est)
2542 d = self.theclass(23, 59, 0, tzinfo=met) 2542 d = self.theclass(23, 59, 0, tzinfo=met)
2543 2543
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3822 datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month, 3822 datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month,
3823 as_date.day, 0, 0, 0) 3823 as_date.day, 0, 0, 0)
3824 self.assertEqual(as_datetime, datetime_sc) 3824 self.assertEqual(as_datetime, datetime_sc)
3825 self.assertEqual(datetime_sc, as_datetime) 3825 self.assertEqual(datetime_sc, as_datetime)
3826 3826
3827 def test_main(): 3827 def test_main():
3828 support.run_unittest(__name__) 3828 support.run_unittest(__name__)
3829 3829
3830 if __name__ == "__main__": 3830 if __name__ == "__main__":
3831 test_main() 3831 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+