'Test the |localtime, |utc, and |timezone filters on bad inputs.'

def test_localtime_filters_do_not_raise_exceptions(self):

    tpl = Template(u'{%    load    tz    %}{{    dt    }}|{{    dt|localtime    }}|{{    dt|utc    }}|{{    dt|timezone:tz    }}')
    with self.settings(USE_TZ=True):
        ctx = Context({u'dt': None, u'tz': ICT})
        self.assertEqual(tpl.render(ctx), u'None|||')
        ctx = Context({u'dt': u'not    a    date', u'tz': ICT})
        self.assertEqual(tpl.render(ctx), u'not    a    date|||')
        tpl = Template(u'{%    load    tz    %}{{    dt|timezone:tz    }}')
        ctx = Context({u'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), u'tz': None})
        self.assertEqual(tpl.render(ctx), u'')
        ctx = Context({u'dt': datetime.datetime(2011, 9, 1, 13, 20, 30), u'tz': u'not    a    tz'})
        self.assertEqual(tpl.render(ctx), u'')
