25
25
from pylint .reporters .ureports .nodes import EvaluationSection
26
26
27
27
expected_score_message = "Expected score message"
28
-
29
-
30
- def test_simple_json_output_no_score () -> None :
31
- """Test JSON reporter with no score"""
32
- message = {
33
- "msg" : "line-too-long" ,
34
- "line" : 1 ,
35
- "args" : (1 , 2 ),
36
- "end_line" : None ,
37
- "end_column" : None ,
38
- }
39
- expected = [
40
- [
41
- ("column" , 0 ),
42
- ("end_column" , None ),
43
- ("end_line" , None ),
44
- ("line" , 1 ),
45
- ("message" , "Line too long (1/2)" ),
46
- ("message-id" , "C0301" ),
47
- ("module" , "0123" ),
48
- ("obj" , "" ),
49
- ("path" , "0123" ),
50
- ("symbol" , "line-too-long" ),
51
- ("type" , "convention" ),
52
- ]
28
+ expected_result = [
29
+ [
30
+ ("column" , 0 ),
31
+ ("line" , 1 ),
32
+ ("message" , "Line too long (1/2)" ),
33
+ ("message-id" , "C0301" ),
34
+ ("module" , "0123" ),
35
+ ("obj" , "" ),
36
+ ("path" , "0123" ),
37
+ ("symbol" , "line-too-long" ),
38
+ ("type" , "convention" ),
53
39
]
54
- report = get_linter_result (score = False , message = message )
55
- assert len (report ) == 1
56
- report_result = [sorted (report [0 ].items (), key = lambda item : item [0 ])]
57
- assert report_result == expected
40
+ ]
58
41
59
42
60
- def test_simple_json_output_no_score_with_end_line () -> None :
61
- """Test JSON reporter with no score with end_line and end_column"""
62
- message = {
63
- "msg" : "line-too-long" ,
64
- "line" : 1 ,
65
- "args" : (1 , 2 ),
66
- "end_line" : 1 ,
67
- "end_column" : 4 ,
68
- }
69
- expected = [
70
- [
71
- ("column" , 0 ),
72
- ("end_column" , 4 ),
73
- ("end_line" , 1 ),
74
- ("line" , 1 ),
75
- ("message" , "Line too long (1/2)" ),
76
- ("message-id" , "C0301" ),
77
- ("module" , "0123" ),
78
- ("obj" , "" ),
79
- ("path" , "0123" ),
80
- ("symbol" , "line-too-long" ),
81
- ("type" , "convention" ),
82
- ]
83
- ]
84
- report = get_linter_result (score = False , message = message )
43
+ def test_simple_json_output_no_score () -> None :
44
+ report = get_linter_result (score = False )
85
45
assert len (report ) == 1
86
46
report_result = [sorted (report [0 ].items (), key = lambda item : item [0 ])]
87
- assert report_result == expected
47
+ assert report_result == expected_result
88
48
89
49
90
- def get_linter_result (score : bool , message : Dict [ str , Any ] ) -> List [Dict [str , Any ]]:
50
+ def get_linter_result (score : bool ) -> List [Dict [str , Any ]]:
91
51
output = StringIO ()
92
52
reporter = JSONReporter (output )
93
53
linter = PyLinter (reporter = reporter )
@@ -96,13 +56,7 @@ def get_linter_result(score: bool, message: Dict[str, Any]) -> List[Dict[str, An
96
56
linter .config .score = score
97
57
linter .open ()
98
58
linter .set_current_module ("0123" )
99
- linter .add_message (
100
- message ["msg" ],
101
- line = message ["line" ],
102
- args = message ["args" ],
103
- end_lineno = message ["end_line" ],
104
- end_col_offset = message ["end_column" ],
105
- )
59
+ linter .add_message ("line-too-long" , line = 1 , args = (1 , 2 ))
106
60
# we call those methods because we didn't actually run the checkers
107
61
if score :
108
62
reporter .display_reports (EvaluationSection (expected_score_message ))
0 commit comments