()
| 646 | raise RuntimeError("Expected sys.audit(9) to fail.") |
| 647 | |
| 648 | def test_sys_remote_exec(): |
| 649 | import tempfile |
| 650 | |
| 651 | pid = os.getpid() |
| 652 | event_pid = -1 |
| 653 | event_script_path = "" |
| 654 | remote_event_script_path = "" |
| 655 | def hook(event, args): |
| 656 | if event not in ["sys.remote_exec", "cpython.remote_debugger_script"]: |
| 657 | return |
| 658 | print(event, args) |
| 659 | match event: |
| 660 | case "sys.remote_exec": |
| 661 | nonlocal event_pid, event_script_path |
| 662 | event_pid = args[0] |
| 663 | event_script_path = args[1] |
| 664 | case "cpython.remote_debugger_script": |
| 665 | nonlocal remote_event_script_path |
| 666 | remote_event_script_path = args[0] |
| 667 | |
| 668 | sys.addaudithook(hook) |
| 669 | with tempfile.NamedTemporaryFile(mode='w+', delete=True) as tmp_file: |
| 670 | tmp_file.write("a = 1+1\n") |
| 671 | tmp_file.flush() |
| 672 | sys.remote_exec(pid, tmp_file.name) |
| 673 | assertEqual(event_pid, pid) |
| 674 | assertEqual(event_script_path, tmp_file.name) |
| 675 | assertEqual(remote_event_script_path, tmp_file.name) |
| 676 | |
| 677 | def test_import_module(): |
| 678 | import importlib |
nothing calls this directly
no test coverage detected
searching dependent graphs…