(case_setup, skip_suspend_on_breakpoint_exception, skip_print_breakpoint_exception)
| 153 | ), |
| 154 | ) |
| 155 | def test_case_breakpoint_condition_exc(case_setup, skip_suspend_on_breakpoint_exception, skip_print_breakpoint_exception): |
| 156 | msgs_in_stderr = ( |
| 157 | "Error while evaluating expression in conditional breakpoint: i > 5", |
| 158 | "Traceback (most recent call last):", |
| 159 | 'File "<string>", line 1, in <module>', |
| 160 | ) |
| 161 | |
| 162 | # It could be one or the other in PyPy depending on the version. |
| 163 | msgs_one_in_stderr = ( |
| 164 | "NameError: name 'i' is not defined", |
| 165 | "global name 'i' is not defined", |
| 166 | ) |
| 167 | |
| 168 | def _ignore_stderr_line(line): |
| 169 | if original_ignore_stderr_line(line): |
| 170 | return True |
| 171 | |
| 172 | for msg in msgs_in_stderr + msgs_one_in_stderr: |
| 173 | if msg in line: |
| 174 | return True |
| 175 | |
| 176 | return False |
| 177 | |
| 178 | with case_setup.test_file("_debugger_case_breakpoint_condition_exc.py") as writer: |
| 179 | original_ignore_stderr_line = writer._ignore_stderr_line |
| 180 | writer._ignore_stderr_line = _ignore_stderr_line |
| 181 | |
| 182 | writer.write_suspend_on_breakpoint_exception(skip_suspend_on_breakpoint_exception, skip_print_breakpoint_exception) |
| 183 | |
| 184 | expect_print = skip_print_breakpoint_exception in ([], ["ValueError"]) |
| 185 | expect_suspend = skip_suspend_on_breakpoint_exception in ([], ["ValueError"]) |
| 186 | |
| 187 | breakpoint_id = writer.write_add_breakpoint(writer.get_line_index_with_content("break here"), "Call", condition="i > 5") |
| 188 | |
| 189 | if not expect_print: |
| 190 | _original = writer.reader_thread.on_message_found |
| 191 | |
| 192 | def on_message_found(found_msg): |
| 193 | for msg in msgs_in_stderr + msgs_one_in_stderr: |
| 194 | assert msg not in found_msg |
| 195 | |
| 196 | writer.reader_thread.on_message_found = on_message_found |
| 197 | |
| 198 | writer.write_make_initial_run() |
| 199 | |
| 200 | def check_error_msg(stderr): |
| 201 | for msg in msgs_in_stderr: |
| 202 | assert msg in stderr |
| 203 | |
| 204 | for msg in msgs_one_in_stderr: |
| 205 | if msg in stderr: |
| 206 | break |
| 207 | else: |
| 208 | raise AssertionError("Did not find any of: %s in stderr: %s" % (msgs_one_in_stderr, stderr)) |
| 209 | |
| 210 | if expect_print: |
| 211 | msg, ctx = writer.wait_for_output() |
| 212 | check_error_msg(msg.replace(">", ">")) |
nothing calls this directly
no test coverage detected