#NEWLINE# def test_format_violations( self ) : #NEWLINE# #INDENT# cmdargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# formatter = JSONFormatter ( cmdargs ) #NEWLINE# violations = [ { #NEWLINE# #INDENT# 'name' : 'ProhibitSomethingEvil' , #NEWLINE# 'level' : Level . WARNING , #NEWLINE# 'description' : 'this code is tooooo evil' , #NEWLINE# 'reference' : 'me' , #NEWLINE# 'position' : { #NEWLINE# #INDENT# 'line' : 1 , #NEWLINE# 'column' : 2 , #NEWLINE# 'path' : Path ( 'path' , 'to' , 'file1' ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'ProhibitSomethingDangerous' , #NEWLINE# 'level' : Level . WARNING , #NEWLINE# 'description' : 'this code is tooooo dangerous' , #NEWLINE# 'reference' : 'you' , #NEWLINE# 'position' : { #NEWLINE# #INDENT# 'line' : 11 , #NEWLINE# 'column' : 21 , #NEWLINE# 'path' : Path ( 'path' , 'to' , 'file2' ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# expected_output = [ { #NEWLINE# #INDENT# 'policy_name' : 'ProhibitSomethingEvil' , #NEWLINE# 'severity' : 'warning' , #NEWLINE# 'description' : 'this code is tooooo evil' , #NEWLINE# 'reference' : 'me' , #NEWLINE# 'line_number' : 1 , #NEWLINE# 'column_number' : 2 , #NEWLINE# 'file_path' : str ( Path ( 'path' , 'to' , 'file1' ) ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'policy_name' : 'ProhibitSomethingDangerous' , #NEWLINE# 'severity' : 'warning' , #NEWLINE# 'description' : 'this code is tooooo dangerous' , #NEWLINE# 'reference' : 'you' , #NEWLINE# 'line_number' : 11 , #NEWLINE# 'column_number' : 21 , #NEWLINE# 'file_path' : str ( Path ( 'path' , 'to' , 'file2' ) ) , #NEWLINE# #UNINDENT# } ] #NEWLINE# json_output = formatter . format_violations ( violations ) #NEWLINE# parsed_output = json . loads ( json_output ) #NEWLINE# self . maxDiff = 1500 #NEWLINE# self . assertEqual ( parsed_output , expected_output )