|
2 | 2 | import itertools |
3 | 3 | import json |
4 | 4 | import os |
| 5 | +import pdb |
5 | 6 | import re |
6 | 7 | import signal |
7 | 8 | import socket |
|
10 | 11 | import textwrap |
11 | 12 | import unittest |
12 | 13 | import unittest.mock |
13 | | -from contextlib import closing, contextmanager, redirect_stdout, redirect_stderr, ExitStack |
14 | | -from test.support import is_wasi, cpython_only, force_color, requires_subprocess, SHORT_TIMEOUT, subTests |
15 | | -from test.support.os_helper import TESTFN, unlink |
| 14 | +from contextlib import ( |
| 15 | + ExitStack, |
| 16 | + closing, |
| 17 | + contextmanager, |
| 18 | + redirect_stderr, |
| 19 | + redirect_stdout, |
| 20 | +) |
| 21 | +from pdb import _PdbClient, _PdbServer |
16 | 22 | from typing import List |
17 | 23 |
|
18 | | -import pdb |
19 | | -from pdb import _PdbServer, _PdbClient |
20 | | - |
| 24 | +from test.support import ( |
| 25 | + SHORT_TIMEOUT, |
| 26 | + cpython_only, |
| 27 | + force_color, |
| 28 | + is_wasi, |
| 29 | + requires_subprocess, |
| 30 | + subTests, |
| 31 | +) |
| 32 | +from test.support.os_helper import TESTFN, unlink |
21 | 33 |
|
22 | 34 | if not sys.is_remote_debug_enabled(): |
23 | 35 | raise unittest.SkipTest('remote debugging is disabled') |
@@ -1594,11 +1606,11 @@ def test_attach_to_non_existent_process(self): |
1594 | 1606 | with force_color(False): |
1595 | 1607 | result = subprocess.run([sys.executable, "-m", "pdb", "-p", "999999"], text=True, capture_output=True) |
1596 | 1608 | self.assertNotEqual(result.returncode, 0) |
1597 | | - error = ( |
1598 | | - "The specified process cannot be attached to due to insufficient permissions." |
1599 | | - if sys.platform == "darwin" else |
1600 | | - "Cannot attach to pid 999999, please make sure that the process exists" |
1601 | | - ) |
| 1609 | + if sys.platform == "darwin": |
| 1610 | + # On MacOS, attaching to a non-existent process gives PermissionError |
| 1611 | + error = "The specified process cannot be attached to due to insufficient permissions" |
| 1612 | + else: |
| 1613 | + error = "Cannot attach to pid 999999, please make sure that the process exists" |
1602 | 1614 | self.assertIn(error, result.stdout) |
1603 | 1615 |
|
1604 | 1616 |
|
|
0 commit comments