@@ -55,35 +55,56 @@ def test_output_line() -> None:
55
55
def test_output_line_from_message (message : Callable ) -> None :
56
56
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg."""
57
57
expected_column = 2 if PY38_PLUS else 0
58
- expected_end_lineno = 1 if PY38_PLUS else None
59
- expected_end_column = 3 if PY38_PLUS else None
60
- output_line = OutputLine .from_msg (message ())
58
+
59
+ output_line = OutputLine .from_msg (message (), True )
61
60
assert output_line .symbol == "missing-docstring"
62
61
assert output_line .lineno == 1
63
62
assert output_line .column == expected_column
64
- assert output_line .end_lineno == expected_end_lineno
65
- assert output_line .end_column == expected_end_column
63
+ assert output_line .end_lineno == 1
64
+ assert output_line .end_column == 3
66
65
assert output_line .object == "obj"
67
66
assert output_line .msg == "msg"
68
67
assert output_line .confidence == "HIGH"
69
68
69
+ output_line_without_end = OutputLine .from_msg (message (), False )
70
+ assert output_line_without_end .symbol == "missing-docstring"
71
+ assert output_line_without_end .lineno == 1
72
+ assert output_line_without_end .column == expected_column
73
+ assert output_line_without_end .end_lineno is None
74
+ assert output_line_without_end .end_column is None
75
+ assert output_line_without_end .object == "obj"
76
+ assert output_line_without_end .msg == "msg"
77
+ assert output_line_without_end .confidence == "HIGH"
78
+
70
79
71
80
@pytest .mark .parametrize ("confidence" , [HIGH , INFERENCE ])
72
81
def test_output_line_to_csv (confidence : Confidence , message : Callable ) -> None :
73
82
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg
74
83
and then converted to csv.
75
84
"""
76
- output_line = OutputLine .from_msg (message (confidence ))
85
+ output_line = OutputLine .from_msg (message (confidence ), True )
77
86
csv = output_line .to_csv ()
78
87
expected_column = "2" if PY38_PLUS else "0"
79
- expected_end_lineno = "1" if PY38_PLUS else "None"
80
- expected_end_column = "3" if PY38_PLUS else "None"
81
88
assert csv == (
82
89
"missing-docstring" ,
83
90
"1" ,
84
91
expected_column ,
85
- expected_end_lineno ,
86
- expected_end_column ,
92
+ "1" ,
93
+ "3" ,
94
+ "obj" ,
95
+ "msg" ,
96
+ confidence .name ,
97
+ )
98
+
99
+ output_line_without_end = OutputLine .from_msg (message (confidence ), False )
100
+ csv = output_line_without_end .to_csv ()
101
+ expected_column = "2" if PY38_PLUS else "0"
102
+ assert csv == (
103
+ "missing-docstring" ,
104
+ "1" ,
105
+ expected_column ,
106
+ "None" ,
107
+ "None" ,
87
108
"obj" ,
88
109
"msg" ,
89
110
confidence .name ,
@@ -96,12 +117,12 @@ def test_output_line_from_csv_error() -> None:
96
117
MalformedOutputLineException ,
97
118
match = "msg-symbolic-name:42:27:MyClass.my_function:The message" ,
98
119
):
99
- OutputLine .from_csv ("'missing-docstring', 'line', 'column', 'obj', 'msg'" )
120
+ OutputLine .from_csv ("'missing-docstring', 'line', 'column', 'obj', 'msg'" , True )
100
121
with pytest .raises (
101
122
MalformedOutputLineException , match = "symbol='missing-docstring' ?"
102
123
):
103
124
csv = ("missing-docstring" , "line" , "column" , "obj" , "msg" )
104
- OutputLine .from_csv (csv )
125
+ OutputLine .from_csv (csv , True )
105
126
106
127
107
128
@pytest .mark .parametrize (
@@ -125,7 +146,7 @@ def test_output_line_from_csv_deprecated(
125
146
else :
126
147
proper_csv = ["missing-docstring" , "1" , "2" , "obj" , "msg" ]
127
148
with pytest .warns (DeprecationWarning ) as records :
128
- output_line = OutputLine .from_csv (proper_csv )
149
+ output_line = OutputLine .from_csv (proper_csv , True )
129
150
assert len (records ) == 1
130
151
131
152
expected_column = 2 if PY38_PLUS else 0
@@ -155,14 +176,25 @@ def test_output_line_from_csv() -> None:
155
176
"msg" ,
156
177
"HIGH" ,
157
178
]
158
- output_line = OutputLine .from_csv (proper_csv )
159
179
expected_column = 2 if PY38_PLUS else 0
160
- expected_end_lineno = 1 if PY38_PLUS else None
180
+
181
+ output_line = OutputLine .from_csv (proper_csv , True )
182
+ assert output_line == OutputLine (
183
+ symbol = "missing-docstring" ,
184
+ lineno = 1 ,
185
+ column = expected_column ,
186
+ end_lineno = 1 ,
187
+ end_column = None ,
188
+ object = "obj" ,
189
+ msg = "msg" ,
190
+ confidence = "HIGH" ,
191
+ )
192
+ output_line = OutputLine .from_csv (proper_csv , False )
161
193
assert output_line == OutputLine (
162
194
symbol = "missing-docstring" ,
163
195
lineno = 1 ,
164
196
column = expected_column ,
165
- end_lineno = expected_end_lineno ,
197
+ end_lineno = None ,
166
198
end_column = None ,
167
199
object = "obj" ,
168
200
msg = "msg" ,
0 commit comments