(case_setup_remote, reattach)
| 3004 | @pytest.mark.skipif(not IS_CPYTHON or IS_MAC or not SUPPORT_ATTACH_TO_PID, reason="CPython only test (brittle on Mac).") |
| 3005 | @pytest.mark.parametrize("reattach", [True, False]) |
| 3006 | def test_attach_to_pid_no_threads(case_setup_remote, reattach): |
| 3007 | with case_setup_remote.test_file("_debugger_case_attach_to_pid_simple.py", wait_for_port=False) as writer: |
| 3008 | time.sleep(1) # Give it some time to initialize to get to the while loop. |
| 3009 | _attach_to_writer_pid(writer) |
| 3010 | |
| 3011 | bp_line = writer.get_line_index_with_content("break here") |
| 3012 | bp_id = writer.write_add_breakpoint(bp_line) |
| 3013 | writer.write_make_initial_run() |
| 3014 | |
| 3015 | hit = writer.wait_for_breakpoint_hit(line=bp_line) |
| 3016 | |
| 3017 | if reattach: |
| 3018 | # This would be the same as a second attach to pid, so, the idea is closing the current |
| 3019 | # connection and then doing a new attach to pid. |
| 3020 | writer.write_remove_breakpoint(bp_id) |
| 3021 | writer.write_run_thread(hit.thread_id) |
| 3022 | |
| 3023 | writer.do_kill() # This will simply close the open sockets without doing anything else. |
| 3024 | time.sleep(1) |
| 3025 | |
| 3026 | t = threading.Thread(target=writer.start_socket) |
| 3027 | t.start() |
| 3028 | wait_for_condition(lambda: hasattr(writer, "port")) |
| 3029 | time.sleep(1) |
| 3030 | writer.process = writer.process |
| 3031 | _attach_to_writer_pid(writer) |
| 3032 | wait_for_condition(lambda: hasattr(writer, "reader_thread")) |
| 3033 | time.sleep(1) |
| 3034 | |
| 3035 | bp_id = writer.write_add_breakpoint(bp_line) |
| 3036 | writer.write_make_initial_run() |
| 3037 | |
| 3038 | hit = writer.wait_for_breakpoint_hit(line=bp_line) |
| 3039 | |
| 3040 | writer.write_change_variable(hit.thread_id, hit.frame_id, "wait", "False") |
| 3041 | writer.wait_for_var('<xml><var name="" type="bool"') |
| 3042 | |
| 3043 | writer.write_run_thread(hit.thread_id) |
| 3044 | |
| 3045 | writer.finished_ok = True |
| 3046 | |
| 3047 | |
| 3048 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected