<s> from nose . tools import raises <EOL> from painter . painter import paint <EOL> paint . enabled = True <EOL> def test_painter_style_string ( ) : <EOL> assert paint . underline ( '<STR_LIT:foo>' ) == '<STR_LIT>' <EOL> assert paint . red ( '<STR_LIT:foo>' ) == '<STR_LIT>' <EOL> assert paint . on_red ( '<STR_LIT:foo>' ) == '<STR_LIT>' <EOL> def test_painter_pattern_string ( ) : <EOL> assert paint . rainbow ( '<STR_LIT>' ) == ( <EOL> '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + <EOL> '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT:U+0020>' + <EOL> '<STR_LIT>' <EOL> ) <EOL> assert paint . zebra ( '<STR_LIT:foo>' ) == '<STR_LIT:f>' + '<STR_LIT>' + '<STR_LIT:o>' <EOL> def test_painter_support_applying_multiple_styles_at_once ( ) : <EOL> assert paint . red . on_green . underline ( '<STR_LIT:foo>' ) == ( <EOL> '<STR_LIT>' <EOL> ) <EOL> assert paint . underline . red . on_green ( '<STR_LIT:foo>' ) == ( <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_painter_support_applying_pattern_and_style_at_once ( ) : <EOL> assert paint . zebra . red ( '<STR_LIT:foo>' ) == ( <EOL> '<STR_LIT>' + '<STR_LIT:o>' + '<STR_LIT>' <EOL> ) <EOL> def test_painter_support_nesting_styles ( ) : <EOL> assert paint . red ( '<STR_LIT:foo>' + paint . underline . on_blue ( '<STR_LIT:bar>' ) + '<STR_LIT:!>' ) == ( <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_painter_reset_all_styles_with_reset ( ) : <EOL> assert paint . reset ( paint . red . on_green . underline ( '<STR_LIT:foo>' ) + '<STR_LIT:foo>' ) == ( <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_painter_supports_grey ( ) : <EOL> assert paint . grey ( '<STR_LIT:foo>' ) == '<STR_LIT>' <EOL> def test_painter_support_variable_number_of_arguments ( ) : <EOL> assert paint . red ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) == '<STR_LIT>' <EOL> def test_painter_support_falsy_values ( ) : <EOL> assert paint . red ( <NUM_LIT:0> ) == '<STR_LIT>' <EOL> @ raises ( AttributeError ) <EOL> def test_painter_raises_exception_on_invalid_color ( ) : <EOL> paint . red . invalid_color ( '<STR_LIT>' ) <EOL> def test_painter_repr ( ) : <EOL> assert repr ( paint . red . on_blue . bold . underline ) == ( <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_painter_dir ( ) : <EOL> for item in [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] : <EOL> yield check_item_in_paint , item <EOL> def check_item_in_paint ( item ) : <EOL> return item in dir ( paint ) <EOL> def test_painter_doesnt_output_escape_codes_if_the_input_is_empty ( ) : <EOL> assert paint . red ( ) == '<STR_LIT>' <EOL> def test_painter_enabled_does_not_output_colors_when_manually_disabled ( ) : <EOL> paint . enabled = False <EOL> assert paint . red ( '<STR_LIT:foo>' ) == '<STR_LIT:foo>' <EOL> paint . enabled = True <EOL> def test_painter_styles_exposes_the_styles_as_ansi_escape_codes ( ) : <EOL> assert paint . styles . red . open == '<STR_LIT>' </s>
