(use_unicode)
| 122 | @pytest.mark.parametrize("use_unicode", _USE_UNICODE) |
| 123 | @pytest.mark.skipif(not IS_PY311_OR_GREATER, reason="Python 3.11 required.") |
| 124 | def test_collect_anchors_binop_1(use_unicode): |
| 125 | from _pydevd_bundle.pydevd_frame_utils import create_frames_list_from_traceback |
| 126 | |
| 127 | if use_unicode: |
| 128 | |
| 129 | def method(): |
| 130 | á = 1 |
| 131 | í = 2 |
| 132 | c = tuple |
| 133 | |
| 134 | result = á + í + c |
| 135 | |
| 136 | else: |
| 137 | |
| 138 | def method(): |
| 139 | a = 1 |
| 140 | b = 2 |
| 141 | c = tuple |
| 142 | |
| 143 | result = a + b + c |
| 144 | |
| 145 | try: |
| 146 | method() |
| 147 | except: |
| 148 | exc_type, exc_desc, trace_obj = sys.exc_info() |
| 149 | memo = {} |
| 150 | frame = None |
| 151 | frames_list = create_frames_list_from_traceback(trace_obj, frame, exc_type, exc_desc, memo) |
| 152 | iter_in = iter(frames_list) |
| 153 | f = next(iter_in) |
| 154 | assert f.f_code.co_name == "method" |
| 155 | line_col_info = frames_list.frame_id_to_line_col_info[id(f)] |
| 156 | |
| 157 | if use_unicode: |
| 158 | line = " result = á + í + c" |
| 159 | expected_index = line.index("á + í") |
| 160 | else: |
| 161 | line = " result = a + b + c" |
| 162 | expected_index = line.index("a + b") |
| 163 | |
| 164 | assert line_col_info.colno == expected_index |
| 165 | |
| 166 | # It's +2 here due to the á and í unicode chars (we need to convert from the bytes |
| 167 | # index to the actual character in the string to get the actual col). |
| 168 | if use_unicode: |
| 169 | assert line_col_info.end_colno == len(line) + 2 |
| 170 | else: |
| 171 | assert line_col_info.end_colno == len(line) |
| 172 | original_line = line |
| 173 | |
| 174 | col, endcol = line_col_info.map_columns_to_line(original_line) |
| 175 | assert col == line.index("+ c") |
| 176 | assert endcol == col + 1 |
| 177 | |
| 178 | |
| 179 | @pytest.mark.parametrize("use_unicode", _USE_UNICODE) |
nothing calls this directly
no test coverage detected