<s> from cleo . formatters import OutputFormatter , OutputFormatterStyle <EOL> from . . import CleoTestCase <EOL> class OutputFormatterTest ( CleoTestCase ) : <EOL> def test_empty_tag ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( '<STR_LIT>' , formatter . format ( '<STR_LIT>' ) ) <EOL> def test_lg_char_escaping ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( '<STR_LIT>' , formatter . format ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> OutputFormatter . escape ( '<STR_LIT>' ) <EOL> ) <EOL> def test_bundled_styles ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT:error>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT:info>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_nested_styles ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_adjacent_style ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_style_matching_non_greedy ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_style_escaping ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' % formatter . escape ( '<STR_LIT>' ) ) <EOL> ) <EOL> def test_deep_nested_style ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_new_style ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> style = OutputFormatterStyle ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> formatter . set_style ( '<STR_LIT:test>' , style ) <EOL> self . assertEqual ( style , formatter . get_style ( '<STR_LIT:test>' ) ) <EOL> self . assertNotEqual ( style , formatter . get_style ( '<STR_LIT:info>' ) ) <EOL> style = OutputFormatterStyle ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> formatter . set_style ( '<STR_LIT:b>' , style ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_redefined_style ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> style = OutputFormatterStyle ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> formatter . set_style ( '<STR_LIT:info>' , style ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_inline_style ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_non_style_tag ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_test_non_decorated_formatter ( self ) : <EOL> formatter = OutputFormatter ( False ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT:error>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT:info>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( formatter . has_style ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> formatter . set_decorated ( True ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> self . assertEqual ( <EOL> '<STR_LIT>' , <EOL> formatter . format ( '<STR_LIT>' ) <EOL> ) <EOL> def test_content_with_line_breaks ( self ) : <EOL> formatter = OutputFormatter ( True ) <EOL> for expected , message in self . provide_content_with_line_breaks ( ) : <EOL> self . assertEqual ( expected , formatter . format ( message ) ) <EOL> def provide_content_with_line_breaks ( self ) : <EOL> return [ <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) <EOL> ] </s>
