summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAlexander Belopolsky <abalkin@users.noreply.github.com>2017-10-24 17:17:10 (GMT)
committerGitHub <noreply@github.com>2017-10-24 17:17:10 (GMT)
commitfdd9b217c60b454ac6a82f02c8b0b551caeac88b (patch)
treed520a2e9344820bf8f7df0f1e0c4ec1882e4eff4 /Lib/test
parenteab3ff72ebe79416cc032b8508ae13332955a157 (diff)
downloadcpython-fdd9b217c60b454ac6a82f02c8b0b551caeac88b.zip
cpython-fdd9b217c60b454ac6a82f02c8b0b551caeac88b.tar.gz
cpython-fdd9b217c60b454ac6a82f02c8b0b551caeac88b.tar.bz2
Closes bpo-28292: Implemented Calendar.itermonthdays3() and itermonthdays4(). (#4079)
Calendar.itermonthdates() will now consistently raise an exception when a date falls outside of the 0001-01-01 through 9999-12-31 range. To support applications that cannot tolerate such exceptions, the new methods itermonthdays3() and itermonthdays4() are added. The new methods return tuples and are not restricted by the range supported by datetime.date. Thanks @serhiy-storchaka for suggesting the itermonthdays4() method and for the review.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_calendar.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index c777f64..ad8b6bb 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -502,10 +502,15 @@ class CalendarTestCase(unittest.TestCase):
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
self.assertEqual(old_october, new_october)
- def test_itermonthdates(self):
- # ensure itermonthdates doesn't overflow after datetime.MAXYEAR
- # see #15421
- list(calendar.Calendar().itermonthdates(datetime.MAXYEAR, 12))
+ def test_itermonthdays3(self):
+ # ensure itermonthdays3 doesn't overflow after datetime.MAXYEAR
+ list(calendar.Calendar().itermonthdays3(datetime.MAXYEAR, 12))
+
+ def test_itermonthdays4(self):
+ cal = calendar.Calendar(firstweekday=3)
+ days = list(cal.itermonthdays4(2001, 2))
+ self.assertEqual(days[0], (2001, 2, 1, 3))
+ self.assertEqual(days[-1], (2001, 2, 28, 2))
def test_itermonthdays(self):
for firstweekday in range(7):
@@ -846,7 +851,8 @@ class MiscTestCase(unittest.TestCase):
blacklist = {'mdays', 'January', 'February', 'EPOCH',
'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY',
'SATURDAY', 'SUNDAY', 'different_locale', 'c',
- 'prweek', 'week', 'format', 'formatstring', 'main'}
+ 'prweek', 'week', 'format', 'formatstring', 'main',
+ 'monthlen', 'prevmonth', 'nextmonth'}
support.check__all__(self, calendar, blacklist=blacklist)