def test_to_json_dict(self): report = PycheckerModuleReport("any.module") report.add_warning(PycheckerWarning("warning 1", 1)) report.add_warning(PycheckerWarning("warning 2", 2)) expected = { "name": "any.module", "warnings": [{"message": "warning 1", "line_number": 1}, {"message": "warning 2", "line_number": 2}] } self.assertEquals(expected, report.to_json_dict())
def test_to_json_dict(self): module_report_one = PycheckerModuleReport("any.module") module_report_one.add_warning(PycheckerWarning("warning 1", 1)) module_report_one.add_warning(PycheckerWarning("warning 2", 2)) module_report_two = PycheckerModuleReport("any.other.module") module_report_two.add_warning(PycheckerWarning("warning 1", 3)) module_report_two.add_warning(PycheckerWarning("warning 2", 4)) report = PycheckerReport() report.add_module_report(module_report_one) report.add_module_report(module_report_two) expected = { "modules": [ { "name": "any.module", "warnings": [{"message": "warning 1", "line_number": 1}, {"message": "warning 2", "line_number": 2}] }, { "name": "any.other.module", "warnings": [{"message": "warning 1", "line_number": 3}, {"message": "warning 2", "line_number": 4}] } ] } self.assertEquals(expected, report.to_json_dict())