def test_weekday_numbered(self):
for year in [2016, 2017]:
for month in range(1, 13):
weekday, days_in_month = calendar.monthrange(year, month)
for day in range(1, days_in_month + 1):
num = int((day - 1) / 7) + 1
builder = WeekdaySetBuilder(year=year, month=month, day=day)
tested_by_name = builder.build(calendar.day_abbr[weekday] + "#" + str(num))
self.assertEquals(tested_by_name, {weekday})
tested_by_value = builder.build(str(weekday) + "#" + str(num))
self.assertEquals(tested_by_value, {weekday})
for other_weekday in range(0, 7):
if other_weekday != weekday:
tested_by_name = builder.build(calendar.day_abbr[other_weekday] + "#" + str(num))
self.assertEquals(tested_by_name, set())
tested_by_value = builder.build(str(other_weekday) + "#" + str(num))
self.assertEquals(tested_by_value, set())
for other_num in range(1, 6):
if num != other_num:
tested_by_name = builder.build(calendar.day_abbr[weekday] + "#" + str(other_num))
self.assertEquals(tested_by_name, set())
tested_by_value = builder.build(str(weekday) + "#" + str(other_num))
self.assertEquals(tested_by_value, set())
weekday = (weekday + 1) % 7
test_weekday_setbuilder.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录