

def test_date(self):
    d = datetime.date(2010, 3, 12)
    raw_date = filters.date
    assert ('date' in self.app.jinja_env.filters.keys())
    app_date = self.app.jinja_env.filters['date']
    self.assertEqual(raw_date(d), '2010-03-12')
    self.assertEqual(app_date(d), '2010-03-12')
    self.assertEqual(raw_date(d, '%m/%d/%Y'), '03/12/2010')
    self.assertEqual(app_date(d, '%m/%d/%Y'), '03/12/2010')
    self.app.config['DEFAULT_DATE_FORMAT'] = '%m/%d/%y'
    self.assertEqual(raw_date(d), '03/12/10')
    self.assertEqual(app_date(d), '03/12/10')
    self.assertEqual(raw_date(d, None), '2010-03-12')
    self.assertEqual(app_date(d, None), '2010-03-12')
    self.assertEqual(raw_date(d, format=None), '2010-03-12')
    self.assertEqual(app_date(d, format=None), '2010-03-12')
    self.app.config['DEFAULT_DATE_FORMAT'] = None
    self.app.config['DEFAULT_DATETIME_FORMAT'] = 'You should not see me.'
    self.assertEqual(raw_date(d), '2010-03-12')
    self.assertEqual(app_date(d), '2010-03-12')

dataset/ETHPy150Open willowtreeapps/tango-core/tests/test_filters.py FiltersTestCase.test_date/original