#NEWLINE# def test_localtime_filters_do_not_raise_exceptions( self ) : #NEWLINE# #INDENT# '\n        Test the |localtime, |utc, and |timezone filters on bad inputs.\n        ' #NEWLINE# tpl = Template ( '{% load tz %}{{ dt }}|{{ dt|localtime }}|{{ dt|utc }}|{{ dt|timezone:tz }}' ) #NEWLINE# with self . settings ( USE_TZ = True ) : #NEWLINE# #INDENT# ctx = Context ( { #NEWLINE# #INDENT# 'dt' : None , #NEWLINE# 'tz' : ICT , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( tpl . render ( tpl ) , 'None|||' ) #NEWLINE# ctx = Context ( { #NEWLINE# #INDENT# 'dt' : 'not a date' , #NEWLINE# 'tz' : ICT , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( tpl . render ( ctx ) , 'not a date|||' ) #NEWLINE# tpl = Template ( '{% load tz %}{{ dt|timezone:tz }}' ) #NEWLINE# ctx = Context ( { #NEWLINE# #INDENT# 'dt' : datetime . datetime ( 2011 , 9 , 1 , 13 , 20 , 30 ) , #NEWLINE# 'tz' : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( tpl . render ( ctx ) , '' ) #NEWLINE# ctx = Context ( { #NEWLINE# #INDENT# 'dt' : datetime . datetime ( 2011 , 9 , 1 , 13 , 20 , 30 ) , #NEWLINE# 'tz' : 'not a tz' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( tpl . render ( ctx ) , '' )