(pyfile, target, run)
| 306 | |
| 307 | @pytest.mark.flaky(retries=2, delay=1) |
| 308 | def test_invalid_breakpoints(pyfile, target, run): |
| 309 | @pyfile |
| 310 | def code_to_debug(): |
| 311 | import debuggee |
| 312 | |
| 313 | debuggee.setup() |
| 314 | |
| 315 | # For markers below, rN = requested breakpoint, eN = expected breakpoint. |
| 316 | # If there's no eN for some rN, it's assumed to be the same line. |
| 317 | # fmt: off |
| 318 | b = True |
| 319 | while b: # @e0-37,e0-38,e0-39 |
| 320 | pass # @r0 |
| 321 | break |
| 322 | |
| 323 | print() # @e1-37 |
| 324 | [ # @r1,e2 |
| 325 | 1, 2, 3, # @e2-37,e2-38 |
| 326 | ] # @r2 |
| 327 | |
| 328 | print() # @e3,e4 |
| 329 | print(1, # @r3 |
| 330 | 2, 3, # @r4 |
| 331 | 4, 5, 6) |
| 332 | # fmt: on |
| 333 | |
| 334 | with debug.Session() as session: |
| 335 | with run(session, target(code_to_debug)): |
| 336 | requested_markers = ["r" + str(i) for i in range(0, 3)] |
| 337 | |
| 338 | bps = session.set_breakpoints(code_to_debug, requested_markers) |
| 339 | actual_lines = [bp["line"] for bp in bps] |
| 340 | |
| 341 | expected_markers = [] |
| 342 | for r in requested_markers: |
| 343 | e_generic = "e" + r[1:] |
| 344 | e_versioned = ( |
| 345 | e_generic |
| 346 | + "-" |
| 347 | + str(sys.version_info.major) |
| 348 | + str(sys.version_info.minor) |
| 349 | ) |
| 350 | for e in e_versioned, e_generic, r: |
| 351 | if e in code_to_debug.lines: |
| 352 | expected_markers.append(e) |
| 353 | break |
| 354 | |
| 355 | expected_lines = [ |
| 356 | code_to_debug.lines[marker] for marker in expected_markers |
| 357 | ] |
| 358 | assert actual_lines == expected_lines |
| 359 | |
| 360 | # Now let's make sure that we hit all of the expected breakpoints, |
| 361 | # and stop where we expect them to be. |
| 362 | |
| 363 | # If there's multiple breakpoints on the same line, we only stop once, |
| 364 | # so remove duplicates first. |
| 365 | expected_lines = sorted(set(expected_lines)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…