<s> import unittest <EOL> from mako . pygen import PythonPrinter , adjust_whitespace <EOL> from StringIO import StringIO <EOL> class GeneratePythonTest ( unittest . TestCase ) : <EOL> def test_generate_normal ( self ) : <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . writeline ( None ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" <EOL> def test_generate_adjusted ( self ) : <EOL> block = """<STR_LIT>""" <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> printer . write_indented_block ( block ) <EOL> printer . close ( ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" <EOL> def test_generate_combo ( self ) : <EOL> block = """<STR_LIT>""" <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . write_indented_block ( block ) <EOL> printer . writeline ( None ) <EOL> printer . writeline ( "<STR_LIT>" ) <EOL> printer . close ( ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" <EOL> def test_multi_line ( self ) : <EOL> block = """<STR_LIT>""" <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> printer . write_indented_block ( block ) <EOL> printer . close ( ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" <EOL> def test_false_unindentor ( self ) : <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> for line in [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> None , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> None <EOL> ] : <EOL> printer . writeline ( line ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" , stream . getvalue ( ) <EOL> def test_backslash_line ( self ) : <EOL> block = """<STR_LIT>""" <EOL> stream = StringIO ( ) <EOL> printer = PythonPrinter ( stream ) <EOL> printer . write_indented_block ( block ) <EOL> printer . close ( ) <EOL> assert stream . getvalue ( ) == """<STR_LIT>""" <EOL> class WhitespaceTest ( unittest . TestCase ) : <EOL> def test_basic ( self ) : <EOL> text = """<STR_LIT>""" <EOL> assert adjust_whitespace ( text ) == """<STR_LIT>""" <EOL> def test_blank_lines ( self ) : <EOL> text = """<STR_LIT>""" <EOL> assert adjust_whitespace ( text ) == """<STR_LIT>""" <EOL> def test_open_quotes_with_pound ( self ) : <EOL> text = '''<STR_LIT>''' <EOL> assert adjust_whitespace ( text ) == '''<STR_LIT>''' <EOL> def test_quote_with_comments ( self ) : <EOL> text = """<STR_LIT>""" <EOL> assert adjust_whitespace ( text ) == """<STR_LIT>""" <EOL> def test_quotes_with_pound ( self ) : <EOL> text = '''<STR_LIT>''' <EOL> assert adjust_whitespace ( text ) == '''<STR_LIT>''' <EOL> def test_quotes ( self ) : <EOL> text = """<STR_LIT>""" <EOL> assert adjust_whitespace ( text ) == """<STR_LIT>""" </s>
