def test_540_cformat_names(self):
     weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
     abbr_weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
     months = [
         "January",
         "February",
         "March",
         "April",
         "May",
         "June",
         "July",
         "August",
         "September",
         "October",
         "November",
         "December",
     ]
     abbr_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat("%a") == abbr_weekdays[wday - 1]
         assert greg.cformat("%A") == weekdays[wday - 1]
         assert greg.cformat("%b") == abbr_months[month - 1]
         assert greg.cformat("%B") == months[month - 1]
 def test_540_cformat_names(self):
     weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
     abbr_weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
     months = ['January', 'February', 'March', 'April', 'May', 'June',
               'July', 'August', 'September', 'October', 'November', 'December']
     abbr_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%a') == abbr_weekdays[wday - 1]
         assert greg.cformat('%A') == weekdays[wday - 1]
         assert greg.cformat('%b') == abbr_months[month - 1]
         assert greg.cformat('%B') == months[month - 1]
예제 #3
0
 def test_530_cformat_numbers(self):
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         doy = test_row[3]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%d') == '{:02d}'.format(day)
         assert greg.cformat('%j') == '{:03d}'.format(doy)
         assert greg.cformat('%m') == '{:02d}'.format(month)
         assert greg.cformat('%w') == '{:d}'.format(wday)
         if year >= 0:
             assert greg.cformat('%y') == ('0' + str(year))[-2:]
             assert greg.cformat('%Y') == '{:04d}'.format(year)
         else:
             assert greg.cformat('%y') == ('0' + str(-year))[-2:]
             assert greg.cformat('%Y') == '-{:04d}'.format(-year)
 def test_530_cformat_numbers(self):
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         doy = test_row[3]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%d') == '{:02d}'.format(day)
         assert greg.cformat('%j') == '{:03d}'.format(doy)
         assert greg.cformat('%m') == '{:02d}'.format(month)
         assert greg.cformat('%w') == '{:d}'.format(wday)
         if year >= 0:
             assert greg.cformat('%y') == ('0' + str(year))[-2:]
             assert greg.cformat('%Y') == '{:04d}'.format(year)
         else:
             assert greg.cformat('%y') == ('0' + str(-year))[-2:]
             assert greg.cformat('%Y') == '-{:04d}'.format(-year)
 def test_530_cformat_numbers(self):
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         doy = test_row[3]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat("%d") == "{:02d}".format(day)
         assert greg.cformat("%j") == "{:03d}".format(doy)
         assert greg.cformat("%m") == "{:02d}".format(month)
         assert greg.cformat("%w") == "{:d}".format(wday)
         if year >= 0:
             assert greg.cformat("%y") == ("0" + str(year))[-2:]
             assert greg.cformat("%Y") == "{:04d}".format(year)
         else:
             assert greg.cformat("%y") == ("0" + str(-year))[-2:]
             assert greg.cformat("%Y") == "-{:04d}".format(-year)
예제 #6
0
 def test_550_cformat_week_number(self):
     for test_row in gregorian_test_data:
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         WNS = test_row[4]
         WNM = test_row[5]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%U') == WNS
         assert greg.cformat('%W') == WNM
 def test_550_cformat_week_number(self):
     for test_row in gregorian_test_data:
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         WNS = test_row[4]
         WNM = test_row[5]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%U')== WNS
         assert greg.cformat('%W') == WNM
예제 #8
0
 def test_560_cformat_percent(self):
     greg = GregorianCalendar(1, 2, 3)
     assert greg.cformat('%') == '%'
     assert greg.cformat('%%') == '%'
     assert greg.cformat('%%%') == '%%'
     assert greg.cformat('abcd%') == 'abcd%'
     assert greg.cformat('%k') == '%k'
     assert greg.cformat('a%k') == 'a%k'
     assert greg.cformat('%k%') == '%k%'
 def test_560_cformat_percent(self):
     greg = GregorianCalendar(1, 2, 3)
     assert greg.cformat('%') == '%'
     assert greg.cformat('%%') == '%'
     assert greg.cformat('%%%') == '%%'
     assert greg.cformat('abcd%') == 'abcd%'
     assert greg.cformat('%k') == '%k'
     assert greg.cformat('a%k') == 'a%k'
     assert greg.cformat('%k%') == '%k%'
 def test_560_cformat_percent(self):
     greg = GregorianCalendar(1, 2, 3)
     assert greg.cformat("%") == "%"
     assert greg.cformat("%%") == "%"
     assert greg.cformat("%%%") == "%%"
     assert greg.cformat("abcd%") == "abcd%"
     assert greg.cformat("%k") == "%k"
     assert greg.cformat("a%k") == "a%k"
     assert greg.cformat("%k%") == "%k%"
예제 #11
0
 def test_540_cformat_names(self):
     weekdays = [
         'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
         'Sunday'
     ]
     abbr_weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
     months = [
         'January', 'February', 'March', 'April', 'May', 'June', 'July',
         'August', 'September', 'October', 'November', 'December'
     ]
     abbr_months = [
         'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
         'Oct', 'Nov', 'Dec'
     ]
     for test_row in gregorian_test_data:
         wday = test_row[1]
         year = test_row[2][0]
         month = test_row[2][1]
         day = test_row[2][2]
         greg = GregorianCalendar(year, month, day)
         assert greg.cformat('%a') == abbr_weekdays[wday - 1]
         assert greg.cformat('%A') == weekdays[wday - 1]
         assert greg.cformat('%b') == abbr_months[month - 1]
         assert greg.cformat('%B') == months[month - 1]
예제 #12
0
 def test_570_cformat_invalid_type(self):
     greg = GregorianCalendar(1, 2, 3)
     for par in (1, (1, ), [1], {1: 1}, None):
         with pytest.raises(TypeError):
             greg.cformat(par)
 def test_570_cformat_invalid_type(self):
     greg = GregorianCalendar(1, 2, 3)
     for par in (1, (1,), [1], {1: 1}, None):
         with pytest.raises(TypeError):
             greg.cformat(par)