

@requires_pytz
def test_localtime_filters_with_pytz(self):
    '\n        Test the |localtime, |utc, and |timezone filters with pytz.\n        '
    tpl = Template('{% load tz %}{{ dt|localtime }}|{{ dt|utc }}')
    ctx = Context({
        'dt': datetime.datetime(2011, 9, 1, 12, 20, 30),
    })
    with self.settings(TIME_ZONE='Europe/Paris'):
        self.assertEqual(tpl.render(ctx), '2011-09-01T12:20:30+02:00|2011-09-01T10:20:30+00:00')
    tpl = Template('{% load tz %}{{ dt|timezone:tz }}')
    ctx = Context({
        'dt': datetime.datetime(2011, 9, 1, 13, 20, 30),
        'tz': pytz.timezone('Europe/Paris'),
    })
    self.assertEqual(tpl.render(ctx), '2011-09-01T12:20:30+02:00')
    tpl = Template("{% load tz %}{{ dt|timezone:'Europe/Paris' }}")
    ctx = Context({
        'dt': datetime.datetime(2011, 9, 1, 13, 20, 30),
        'tz': pytz.timezone('Europe/Paris'),
    })
    self.assertEqual(tpl.render(ctx), '2011-09-01T12:20:30+02:00')

dataset/ETHPy150Open django/django/tests/timezones/tests.py TemplateTests.test_localtime_filters_with_pytz/original