<s> import re <EOL> import unittest <EOL> from django . template import Template , Context , add_to_builtins <EOL> from django . utils . html import escape <EOL> add_to_builtins ( '<STR_LIT>' ) <EOL> class Templates ( unittest . TestCase ) : <EOL> def test_textile ( self ) : <EOL> try : <EOL> import textile <EOL> except ImportError : <EOL> textile = None <EOL> textile_content = """<STR_LIT>""" <EOL> t = Template ( "<STR_LIT>" ) <EOL> rendered = t . render ( Context ( locals ( ) ) ) . strip ( ) <EOL> if textile : <EOL> self . assertEqual ( rendered . replace ( '<STR_LIT:\t>' , '<STR_LIT>' ) , """<STR_LIT>""" ) <EOL> else : <EOL> self . assertEqual ( rendered , escape ( textile_content ) ) <EOL> def test_markdown ( self ) : <EOL> try : <EOL> import markdown <EOL> except ImportError : <EOL> markdown = None <EOL> markdown_content = """<STR_LIT>""" <EOL> t = Template ( "<STR_LIT>" ) <EOL> rendered = t . render ( Context ( locals ( ) ) ) . strip ( ) <EOL> if markdown : <EOL> pattern = re . compile ( """<STR_LIT>""" ) <EOL> self . assert_ ( pattern . match ( rendered ) ) <EOL> else : <EOL> self . assertEqual ( rendered , markdown_content ) <EOL> def test_docutils ( self ) : <EOL> try : <EOL> import docutils <EOL> except ImportError : <EOL> docutils = None <EOL> rest_content = """<STR_LIT>""" <EOL> t = Template ( "<STR_LIT>" ) <EOL> rendered = t . render ( Context ( locals ( ) ) ) . strip ( ) <EOL> if docutils : <EOL> try : <EOL> self . assertEqual ( rendered , """<STR_LIT>""" ) <EOL> except AssertionError , e : <EOL> self . assertEqual ( rendered , """<STR_LIT>""" ) <EOL> else : <EOL> self . assertEqual ( rendered , rest_content ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
