'Test the |localtime, |utc, and |timezone filters with pytz.'

@skipIf((pytz is None), u'this    test    requires    pytz')
def test_localtime_filters_with_pytz(self):

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