(self)
| 1496 | self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1) |
| 1497 | |
| 1498 | def test_isocalendar(self): |
| 1499 | # Check examples from |
| 1500 | # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm |
| 1501 | week_mondays = [ |
| 1502 | ((2003, 12, 22), (2003, 52, 1)), |
| 1503 | ((2003, 12, 29), (2004, 1, 1)), |
| 1504 | ((2004, 1, 5), (2004, 2, 1)), |
| 1505 | ((2009, 12, 21), (2009, 52, 1)), |
| 1506 | ((2009, 12, 28), (2009, 53, 1)), |
| 1507 | ((2010, 1, 4), (2010, 1, 1)), |
| 1508 | ] |
| 1509 | |
| 1510 | test_cases = [] |
| 1511 | for cal_date, iso_date in week_mondays: |
| 1512 | base_date = self.theclass(*cal_date) |
| 1513 | # Adds one test case for every day of the specified weeks |
| 1514 | for i in range(7): |
| 1515 | new_date = base_date + timedelta(i) |
| 1516 | new_iso = iso_date[0:2] + (iso_date[2] + i,) |
| 1517 | test_cases.append((new_date, new_iso)) |
| 1518 | |
| 1519 | for d, exp_iso in test_cases: |
| 1520 | with self.subTest(d=d, comparison="tuple"): |
| 1521 | self.assertEqual(d.isocalendar(), exp_iso) |
| 1522 | |
| 1523 | # Check that the tuple contents are accessible by field name |
| 1524 | with self.subTest(d=d, comparison="fields"): |
| 1525 | t = d.isocalendar() |
| 1526 | self.assertEqual((t.year, t.week, t.weekday), exp_iso) |
| 1527 | |
| 1528 | def test_isocalendar_pickling(self): |
| 1529 | """Test that the result of datetime.isocalendar() can be pickled. |
nothing calls this directly
no test coverage detected