<s> import unittest <EOL> from pybuilder . plugins . python . pychecker_plugin import ( PycheckerModuleReport , <EOL> PycheckerWarning , <EOL> PycheckerReport , <EOL> parse_pychecker_output ) <EOL> from test_utils import Mock <EOL> class PycheckerWarningTest ( unittest . TestCase ) : <EOL> def test_to_json_dict ( self ) : <EOL> expected = { <EOL> "<STR_LIT:message>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> self . assertEquals ( <EOL> expected , PycheckerWarning ( "<STR_LIT>" , <NUM_LIT> ) . to_json_dict ( ) ) <EOL> class PycheckerModuleReportTest ( unittest . TestCase ) : <EOL> def test_to_json_dict ( self ) : <EOL> report = PycheckerModuleReport ( "<STR_LIT>" ) <EOL> report . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:1> ) ) <EOL> report . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> expected = { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:1> } , <EOL> { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:2> } ] <EOL> } <EOL> self . assertEquals ( expected , report . to_json_dict ( ) ) <EOL> class PycheckerReportTest ( unittest . TestCase ) : <EOL> def test_to_json_dict ( self ) : <EOL> module_report_one = PycheckerModuleReport ( "<STR_LIT>" ) <EOL> module_report_one . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:1> ) ) <EOL> module_report_one . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> module_report_two = PycheckerModuleReport ( "<STR_LIT>" ) <EOL> module_report_two . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:3> ) ) <EOL> module_report_two . add_warning ( PycheckerWarning ( "<STR_LIT>" , <NUM_LIT:4> ) ) <EOL> report = PycheckerReport ( ) <EOL> report . add_module_report ( module_report_one ) <EOL> report . add_module_report ( module_report_two ) <EOL> expected = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:1> } , <EOL> { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:2> } ] <EOL> } , <EOL> { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:3> } , <EOL> { "<STR_LIT:message>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:4> } ] <EOL> } <EOL> ] <EOL> } <EOL> self . assertEquals ( expected , report . to_json_dict ( ) ) <EOL> class ParsePycheckerOutputTest ( unittest . TestCase ) : <EOL> def test_should_parse_report ( self ) : <EOL> project = Mock ( ) <EOL> project . expand_path . return_value = "<STR_LIT>" <EOL> warnings = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> report = parse_pychecker_output ( project , warnings ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( report . module_reports ) ) <EOL> self . assertEquals ( "<STR_LIT>" , report . module_reports [ <NUM_LIT:0> ] . name ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( report . module_reports [ <NUM_LIT:0> ] . warnings ) ) <EOL> self . assertEquals ( <EOL> "<STR_LIT>" , report . module_reports [ <NUM_LIT:0> ] . warnings [ <NUM_LIT:0> ] . message ) <EOL> self . assertEquals ( <NUM_LIT:2> , report . module_reports [ <NUM_LIT:0> ] . warnings [ <NUM_LIT:0> ] . line_number ) <EOL> self . assertEquals ( "<STR_LIT>" , <EOL> report . module_reports [ <NUM_LIT:0> ] . warnings [ <NUM_LIT:1> ] . message ) <EOL> self . assertEquals ( <NUM_LIT:4> , report . module_reports [ <NUM_LIT:0> ] . warnings [ <NUM_LIT:1> ] . line_number ) <EOL> self . assertEquals ( "<STR_LIT>" , report . module_reports [ <NUM_LIT:1> ] . name ) <EOL> self . assertEquals ( <NUM_LIT:2> , len ( report . module_reports [ <NUM_LIT:1> ] . warnings ) ) <EOL> self . assertEquals ( "<STR_LIT>" , <EOL> report . module_reports [ <NUM_LIT:1> ] . warnings [ <NUM_LIT:0> ] . message ) <EOL> self . assertEquals ( <NUM_LIT> , report . module_reports [ <NUM_LIT:1> ] . warnings [ <NUM_LIT:0> ] . line_number ) <EOL> self . assertEquals ( "<STR_LIT>" , <EOL> report . module_reports [ <NUM_LIT:1> ] . warnings [ <NUM_LIT:1> ] . message ) <EOL> self . assertEquals ( <EOL> <NUM_LIT> , report . module_reports [ <NUM_LIT:1> ] . warnings [ <NUM_LIT:1> ] . line_number ) </s>
