<s> from common import * <EOL> from logcatcolor . format import * <EOL> import unittest <EOL> MARKER_LINE = "<STR_LIT>" <EOL> BRIEF_LINE = "<STR_LIT>" <EOL> PROCESS_LINE = "<STR_LIT>" <EOL> TAG_LINE = "<STR_LIT>" <EOL> THREAD_LINE = "<STR_LIT>" <EOL> TIME_LINE = "<STR_LIT>" <EOL> THREAD_TIME_LINE = "<STR_LIT>" <EOL> LONG_LINES = [ "<STR_LIT>" , "<STR_LIT:message>" ] <EOL> def format_test ( FormatType ) : <EOL> def run_format_test ( fn ) : <EOL> def wrapped ( self ) : <EOL> fn ( self , FormatType ( ) ) <EOL> return wrapped <EOL> return run_format_test <EOL> class FormatTest ( unittest . TestCase ) : <EOL> @ format_test ( BriefFormat ) <EOL> def test_marker ( self , format ) : <EOL> self . assertNotEqual ( Format . MARKER_REGEX . match ( MARKER_LINE ) , None ) <EOL> @ format_test ( BriefFormat ) <EOL> def test_brief_format ( self , format ) : <EOL> self . assertTrue ( format . match ( BRIEF_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , None ) <EOL> @ format_test ( ProcessFormat ) <EOL> def test_process_format ( self , format ) : <EOL> self . assertTrue ( format . match ( PROCESS_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , None ) <EOL> @ format_test ( TagFormat ) <EOL> def test_tag_format ( self , format ) : <EOL> self . assertTrue ( format . match ( TAG_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , None ) <EOL> @ format_test ( ThreadFormat ) <EOL> def test_thread_format ( self , format ) : <EOL> self . assertTrue ( format . match ( THREAD_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , None ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , None ) <EOL> @ format_test ( TimeFormat ) <EOL> def test_time_format ( self , format ) : <EOL> self . assertTrue ( format . match ( TIME_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:D>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , None ) <EOL> @ format_test ( ThreadTimeFormat ) <EOL> def test_thread_time_format ( self , format ) : <EOL> self . assertTrue ( format . match ( THREAD_TIME_LINE ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , "<STR_LIT>" ) <EOL> @ format_test ( LongFormat ) <EOL> def test_long_format ( self , format ) : <EOL> self . assertFalse ( format . match ( LONG_LINES [ <NUM_LIT:0> ] ) ) <EOL> self . assertTrue ( format . match ( LONG_LINES [ <NUM_LIT:1> ] ) ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT:I>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:date>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:time>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( format . get ( "<STR_LIT:message>" ) , "<STR_LIT:message>" ) <EOL> def test_detect_format ( self ) : <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , BRIEF_LINE ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , PROCESS_LINE ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , TAG_LINE ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , THREAD_LINE ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , TIME_LINE ] ) , "<STR_LIT:time>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , THREAD_TIME_LINE ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE , LONG_LINES [ <NUM_LIT:0> ] , LONG_LINES [ <NUM_LIT:1> ] ] ) , "<STR_LIT>" ) <EOL> self . assertEqual ( detect_format ( [ MARKER_LINE ] ) , None ) </s>
