def test_format_date_month_year(self): # Given date = '2017-01' # When with self.app_request_context('/'): format_value = format_date(self.autoescape_context, date) # Then self.assertEqual(format_value, "<span class='date'>January 2017</span>")
def test_format_old_date_does_not_change_timezone(self): """ Flask Babel shows some strange behaviour with dates prior to 1902. This appears to be because of a bug in pytz relating to 32 bit time_t types To avoid it, `datetimes` are converted to `date` objects before being passed to `flask_babel.format_date()`. """ date = '1901-01-01' with self.app_request_context('/'): format_value = format_date(self.autoescape_context, date) assert format_value.striptags() == '1 January 1901'