MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_collect_anchors_binop_2

Function test_collect_anchors_binop_2

tests_python/test_frame_utils.py:181–235  ·  view source on GitHub ↗
(use_unicode)

Source from the content-addressed store, hash-verified

179@pytest.mark.parametrize("use_unicode", _USE_UNICODE)
180@pytest.mark.skipif(not IS_PY311_OR_GREATER, reason="Python 3.11 required.")
181def test_collect_anchors_binop_2(use_unicode):
182 from _pydevd_bundle.pydevd_frame_utils import create_frames_list_from_traceback
183
184 if use_unicode:
185
186 def method():
187 á = 1
188 í = 2
189 c = tuple
190
191 result = á + c + í
192
193 else:
194
195 def method():
196 a = 1
197 b = 2
198 c = tuple
199
200 result = a + c + b
201
202 try:
203 method()
204 except:
205 exc_type, exc_desc, trace_obj = sys.exc_info()
206 memo = {}
207 frame = None
208 frames_list = create_frames_list_from_traceback(trace_obj, frame, exc_type, exc_desc, memo)
209 iter_in = iter(frames_list)
210 f = next(iter_in)
211 assert f.f_code.co_name == "method"
212 line_col_info = frames_list.frame_id_to_line_col_info[id(f)]
213
214 if use_unicode:
215 line = " result = á + c + í"
216 expected_index = line.index("á + c")
217 else:
218 line = " result = a + c + b"
219 expected_index = line.index("a + c")
220
221 assert line_col_info.colno == expected_index
222
223 # It's +2 here due to the á and í unicode chars (we need to convert from the bytes
224 # index to the actual character in the string to get the actual col).
225 if use_unicode:
226 assert line_col_info.end_colno == line.index("c + í") + 2
227 else:
228 assert line_col_info.end_colno == line.index("c + b") + 1
229 original_line = line
230
231 col, endcol = line_col_info.map_columns_to_line(original_line)
232 assert col == 23
233 assert endcol == 24
234 assert col == line.index("+ c")
235 assert endcol == col + 1

Callers

nothing calls this directly

Calls 3

map_columns_to_lineMethod · 0.80
methodFunction · 0.70

Tested by

no test coverage detected