<s> """<STR_LIT>""" <EOL> import sys <EOL> import textwrap <EOL> import unittest <EOL> from yapf . yapflib import blank_line_calculator <EOL> from yapf . yapflib import comment_splicer <EOL> from yapf . yapflib import pytree_unwrapper <EOL> from yapf . yapflib import pytree_utils <EOL> from yapf . yapflib import pytree_visitor <EOL> from yapf . yapflib import reformatter <EOL> from yapf . yapflib import split_penalty <EOL> from yapf . yapflib import style <EOL> from yapf . yapflib import subtype_assigner <EOL> class BlankLineCalculatorTest ( unittest . TestCase ) : <EOL> def testDecorators ( self ) : <EOL> unformatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> expected_formatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( unformatted_code ) <EOL> self . assertEqual ( expected_formatted_code , reformatter . Reformat ( uwlines ) ) <EOL> def testComplexDecorators ( self ) : <EOL> unformatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> expected_formatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( unformatted_code ) <EOL> self . assertEqual ( expected_formatted_code , reformatter . Reformat ( uwlines ) ) <EOL> def testCodeAfterFunctionsAndClasses ( self ) : <EOL> unformatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> expected_formatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( unformatted_code ) <EOL> self . assertEqual ( expected_formatted_code , reformatter . Reformat ( uwlines ) ) <EOL> def testCommentSpacing ( self ) : <EOL> unformatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> expected_formatted_code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( unformatted_code ) <EOL> self . assertEqual ( expected_formatted_code , reformatter . Reformat ( uwlines ) ) <EOL> def testCommentBeforeMethod ( self ) : <EOL> code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( code ) <EOL> self . assertEqual ( code , reformatter . Reformat ( uwlines ) ) <EOL> def testCommentsBeforeClassDefs ( self ) : <EOL> code = textwrap . dedent ( '''<STR_LIT>''' ) <EOL> uwlines = _ParseAndUnwrap ( code ) <EOL> self . assertEqual ( code , reformatter . Reformat ( uwlines ) ) <EOL> def testComemntsBeforeDecorator ( self ) : <EOL> code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( code ) <EOL> self . assertEqual ( code , reformatter . Reformat ( uwlines ) ) <EOL> code = textwrap . dedent ( """<STR_LIT>""" ) <EOL> uwlines = _ParseAndUnwrap ( code ) <EOL> self . assertEqual ( code , reformatter . Reformat ( uwlines ) ) <EOL> def _ParseAndUnwrap ( code , dumptree = False ) : <EOL> """<STR_LIT>""" <EOL> style . SetGlobalStyle ( style . CreateChromiumStyle ( ) ) <EOL> tree = pytree_utils . ParseCodeToTree ( code ) <EOL> comment_splicer . SpliceComments ( tree ) <EOL> subtype_assigner . AssignSubtypes ( tree ) <EOL> split_penalty . ComputeSplitPenalties ( tree ) <EOL> blank_line_calculator . CalculateBlankLines ( tree ) <EOL> if dumptree : <EOL> pytree_visitor . DumpPyTree ( tree , target_stream = sys . stderr ) <EOL> uwlines = pytree_unwrapper . UnwrapPyTree ( tree ) <EOL> for uwl in uwlines : <EOL> uwl . CalculateFormattingInformation ( ) <EOL> return uwlines <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
