@@ -70,13 +70,33 @@ def test_output_line_from_message(message: _MessageCallable) -> None:
70
70
assert output_line .msg == "msg"
71
71
assert output_line .confidence == "HIGH"
72
72
73
+ output_line_with_end = OutputLine .from_msg (message (), True )
74
+ assert output_line_with_end .symbol == "missing-docstring"
75
+ assert output_line_with_end .lineno == 1
76
+ assert output_line_with_end .column == 2
77
+ assert output_line_with_end .end_lineno == 1
78
+ assert output_line_with_end .end_column == 3
79
+ assert output_line_with_end .object == "obj"
80
+ assert output_line_with_end .msg == "msg"
81
+ assert output_line_with_end .confidence == "HIGH"
82
+
83
+ output_line_without_end = OutputLine .from_msg (message (), False )
84
+ assert output_line_without_end .symbol == "missing-docstring"
85
+ assert output_line_without_end .lineno == 1
86
+ assert output_line_without_end .column == 2
87
+ assert output_line_without_end .end_lineno is None
88
+ assert output_line_without_end .end_column is None
89
+ assert output_line_without_end .object == "obj"
90
+ assert output_line_without_end .msg == "msg"
91
+ assert output_line_without_end .confidence == "HIGH"
92
+
73
93
74
94
@pytest .mark .parametrize ("confidence" , [HIGH , INFERENCE ])
75
95
def test_output_line_to_csv (confidence : Confidence , message : _MessageCallable ) -> None :
76
96
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg
77
97
and then converted to csv.
78
98
"""
79
- output_line = OutputLine .from_msg (message (confidence ))
99
+ output_line = OutputLine .from_msg (message (confidence ), True )
80
100
csv = output_line .to_csv ()
81
101
assert csv == (
82
102
"missing-docstring" ,
@@ -89,6 +109,19 @@ def test_output_line_to_csv(confidence: Confidence, message: _MessageCallable) -
89
109
confidence .name ,
90
110
)
91
111
112
+ output_line_without_end = OutputLine .from_msg (message (confidence ), False )
113
+ csv = output_line_without_end .to_csv ()
114
+ assert csv == (
115
+ "missing-docstring" ,
116
+ "1" ,
117
+ "2" ,
118
+ "None" ,
119
+ "None" ,
120
+ "obj" ,
121
+ "msg" ,
122
+ confidence .name ,
123
+ )
124
+
92
125
93
126
def test_output_line_from_csv () -> None :
94
127
"""Test that the OutputLine NamedTuple is instantiated correctly with from_csv.
@@ -107,3 +140,25 @@ def test_output_line_from_csv() -> None:
107
140
msg = "msg" ,
108
141
confidence = "HIGH" ,
109
142
)
143
+ output_line_with_end = OutputLine .from_csv (proper_csv , True )
144
+ assert output_line_with_end == OutputLine (
145
+ symbol = "missing-docstring" ,
146
+ lineno = 1 ,
147
+ column = 2 ,
148
+ end_lineno = 1 ,
149
+ end_column = None ,
150
+ object = "obj" ,
151
+ msg = "msg" ,
152
+ confidence = "HIGH" ,
153
+ )
154
+ output_line_without_end = OutputLine .from_csv (proper_csv , False )
155
+ assert output_line_without_end == OutputLine (
156
+ symbol = "missing-docstring" ,
157
+ lineno = 1 ,
158
+ column = 2 ,
159
+ end_lineno = None ,
160
+ end_column = None ,
161
+ object = "obj" ,
162
+ msg = "msg" ,
163
+ confidence = "HIGH" ,
164
+ )
0 commit comments