<s> """<STR_LIT>""" <EOL> import py <EOL> import pytest <EOL> from colorclass . codes import ANSICodeMapping <EOL> from colorclass . color import Color <EOL> from colorclass . core import ColorStr , PARENT_CLASS <EOL> PROJECT_ROOT = py . path . local ( __file__ ) . dirpath ( ) . join ( '<STR_LIT:..>' ) <EOL> @ pytest . fixture ( autouse = True ) <EOL> def set_defaults ( monkeypatch ) : <EOL> """<STR_LIT>""" <EOL> monkeypatch . setattr ( ANSICodeMapping , '<STR_LIT>' , False ) <EOL> monkeypatch . setattr ( ANSICodeMapping , '<STR_LIT>' , False ) <EOL> def assert_both_values ( actual , expected_plain , expected_color , kind = None ) : <EOL> """<STR_LIT>""" <EOL> if kind . endswith ( '<STR_LIT>' ) : <EOL> assert actual . value_colors == expected_plain <EOL> assert actual . value_no_colors == expected_plain <EOL> assert actual . has_colors is False <EOL> elif kind . endswith ( '<STR_LIT>' ) : <EOL> assert actual . value_colors == expected_color <EOL> assert actual . value_no_colors == expected_plain <EOL> if '<STR_LIT>' in actual . value_colors : <EOL> assert actual . has_colors is True <EOL> else : <EOL> assert actual . has_colors is False <EOL> else : <EOL> assert actual == expected_plain <EOL> if kind . startswith ( '<STR_LIT>' ) : <EOL> assert actual . __class__ == ColorStr <EOL> elif kind . startswith ( '<STR_LIT>' ) : <EOL> assert actual . __class__ == Color <EOL> def get_instance ( kind , sample = None , color = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if kind . startswith ( '<STR_LIT>' ) : <EOL> cls = ColorStr <EOL> elif kind . startswith ( '<STR_LIT>' ) : <EOL> cls = Color <EOL> else : <EOL> cls = PARENT_CLASS <EOL> if sample is None : <EOL> return cls ( ) <EOL> if kind . endswith ( '<STR_LIT>' ) : <EOL> return cls ( sample ) <EOL> elif kind . endswith ( '<STR_LIT>' ) : <EOL> tags = '<STR_LIT>' % color , '<STR_LIT>' % color <EOL> return cls ( tags [ <NUM_LIT:0> ] + sample + tags [ <NUM_LIT:1> ] ) <EOL> return sample </s>
