<s> from robot . api import logger <EOL> class WrongStat ( AssertionError ) : <EOL> ROBOT_CONTINUE_ON_FAILURE = True <EOL> def get_total_stats ( path ) : <EOL> return get_all_stats ( path ) [ <NUM_LIT:0> ] <EOL> def get_tag_stats ( path ) : <EOL> return get_all_stats ( path ) [ <NUM_LIT:1> ] <EOL> def get_suite_stats ( path ) : <EOL> return get_all_stats ( path ) [ <NUM_LIT:2> ] <EOL> def get_all_stats ( path ) : <EOL> logger . info ( '<STR_LIT>' % ( path , path ) , <EOL> html = True ) <EOL> stats_line = _get_stats_line ( path ) <EOL> logger . debug ( '<STR_LIT>' % stats_line ) <EOL> total , tags , suite = eval ( stats_line ) <EOL> return total , tags , suite <EOL> def _get_stats_line ( path ) : <EOL> prefix = '<STR_LIT>' <EOL> with open ( path ) as file : <EOL> for line in file : <EOL> if line . startswith ( prefix ) : <EOL> return line [ len ( prefix ) : - <NUM_LIT:2> ] <EOL> def verify_stat ( stat , * attrs ) : <EOL> stat . pop ( '<STR_LIT>' ) <EOL> expected = dict ( _get_expected_stat ( attrs ) ) <EOL> if stat != expected : <EOL> raise WrongStat ( '<STR_LIT>' % ( '<STR_LIT>' , stat , '<STR_LIT>' , expected ) ) <EOL> def _get_expected_stat ( attrs ) : <EOL> for key , value in ( a . split ( '<STR_LIT::>' , <NUM_LIT:1> ) for a in attrs ) : <EOL> value = int ( value ) if value . isdigit ( ) else str ( value ) <EOL> yield str ( key ) , value </s>
