(pyfile, target, run, error_name)
| 137 | # all other errors, we should be printing traceback. |
| 138 | @pytest.mark.parametrize("error_name", ["NameError", ""]) |
| 139 | def test_error_in_condition(pyfile, target, run, error_name): |
| 140 | error_name = error_name or "ZeroDivisionError" |
| 141 | |
| 142 | condition, expect_traceback = { |
| 143 | "NameError": ("no_such_name", False), |
| 144 | "ZeroDivisionError": ("1 / 0", True), |
| 145 | }[error_name] |
| 146 | |
| 147 | @pyfile |
| 148 | def code_to_debug(): |
| 149 | import debuggee |
| 150 | |
| 151 | debuggee.setup() |
| 152 | for i in range(1, 10): # @bp |
| 153 | pass |
| 154 | |
| 155 | with debug.Session() as session: |
| 156 | with run(session, target(code_to_debug)): |
| 157 | session.request( |
| 158 | "setBreakpoints", |
| 159 | { |
| 160 | "source": {"path": code_to_debug}, |
| 161 | "breakpoints": [ |
| 162 | {"line": code_to_debug.lines["bp"], "condition": condition} |
| 163 | ], |
| 164 | }, |
| 165 | ) |
| 166 | occurrences = session.timeline.all_occurrences_of( |
| 167 | timeline.Event("output", some.dict.containing({"category": "important"})), |
| 168 | ) |
| 169 | |
| 170 | if expect_traceback: |
| 171 | assert len(occurrences) == 10 |
| 172 | for occurrence in occurrences: |
| 173 | assert error_name in occurrence.body['output'] |
| 174 | else: |
| 175 | assert len(occurrences) == 0 |
| 176 | |
| 177 | |
| 178 | @pytest.mark.parametrize("condition", ["condition", ""]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…