

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

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