コード例 #1
0
 def test_530_cformat_numbers(self):
     for test_row in iso_test_data:
         year = test_row[1]
         week = test_row[2]
         day = test_row[3]
         doy = test_row[4]
         iso = IsoCalendar(year, week, day)
         assert iso.cformat('%j') == '{:03d}'.format(doy)
         assert iso.cformat('%w') == '{:1d}'.format(day)
         assert iso.cformat('%W') == '{:02d}'.format(week)
         assert iso.cformat('%y') == ('{:04d}'.format(year))[-2:]
         if year >= 0:
             assert iso.cformat('%Y') == '{:04d}'.format(year)
         else:
             assert iso.cformat('%Y') == '-{:04d}'.format(-year)
コード例 #2
0
 def test_530_cformat_numbers(self):
     for test_row in iso_test_data:
         year = test_row[1]
         week = test_row[2]
         day = test_row[3]
         doy = test_row[4]
         iso = IsoCalendar(year, week, day)
         assert iso.cformat('%j') == '{:03d}'.format(doy)
         assert iso.cformat('%w') == '{:1d}'.format(day)
         assert iso.cformat('%W') == '{:02d}'.format(week)
         assert iso.cformat('%y') == ('{:04d}'.format(year))[-2:]
         if year >= 0:
             assert iso.cformat('%Y') == '{:04d}'.format(year)
         else:
             assert iso.cformat('%Y') == '-{:04d}'.format(-year)
コード例 #3
0
 def test_540_cformat_names(self):
     weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
     abbr_weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
     for test_row in iso_test_data:
         year = test_row[1]
         week = test_row[2]
         day = test_row[3]
         iso = IsoCalendar(year, week, day)
         assert iso.cformat('%a') == abbr_weekdays[day - 1]
         assert iso.cformat('%A') == weekdays[day - 1]
コード例 #4
0
 def test_540_cformat_names(self):
     weekdays = [
         'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
         'Sunday'
     ]
     abbr_weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
     for test_row in iso_test_data:
         year = test_row[1]
         week = test_row[2]
         day = test_row[3]
         iso = IsoCalendar(year, week, day)
         assert iso.cformat('%a') == abbr_weekdays[day - 1]
         assert iso.cformat('%A') == weekdays[day - 1]
コード例 #5
0
 def test_560_cformat_percent(self):
     iso = IsoCalendar(1, 2, 3)
     assert iso.cformat('%') == '%'
     assert iso.cformat('%%') == '%'
     assert iso.cformat('%%%') == '%%'
     assert iso.cformat('abcd%') == 'abcd%'
     assert iso.cformat('%k') == '%k'
     assert iso.cformat('a%k') == 'a%k'
     assert iso.cformat('%k%') == '%k%'
コード例 #6
0
 def test_560_cformat_percent(self):
     iso = IsoCalendar(1, 2, 3)
     assert iso.cformat('%') == '%'
     assert iso.cformat('%%') == '%'
     assert iso.cformat('%%%') == '%%'
     assert iso.cformat('abcd%') == 'abcd%'
     assert iso.cformat('%k') == '%k'
     assert iso.cformat('a%k') == 'a%k'
     assert iso.cformat('%k%') == '%k%'
コード例 #7
0
 def test_570_cformat_invalid_type(self):
     iso = IsoCalendar(1, 2, 3)
     for par in (1, (1, ), [1], {1: 1}, None):
         with pytest.raises(TypeError):
             iso.cformat(par)
コード例 #8
0
 def test_570_cformat_invalid_type(self):
     iso = IsoCalendar(1, 2, 3)
     for par in (1, (1,), [1], {1:1}, None):
         with pytest.raises(TypeError):
             iso.cformat(par)