diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/asyncio/base_subprocess.py | 2 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_subprocess.py | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py index 7c17066..b547c44 100644 --- a/Lib/asyncio/base_subprocess.py +++ b/Lib/asyncio/base_subprocess.py @@ -57,7 +57,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): if self._closed: info.append('closed') if self._pid is not None: - info.append(f'pid={self.pid}') + info.append(f'pid={self._pid}') if self._returncode is not None: info.append(f'returncode={self._returncode}') elif self._pid is not None: diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index 81b08d6..428510f 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -29,6 +29,7 @@ class TestSubprocessTransport(base_subprocess.BaseSubprocessTransport): self._proc.stdin = None self._proc.stdout = None self._proc.stderr = None + self._proc.pid = -1 class SubprocessTransportTests(test_utils.TestCase): @@ -73,6 +74,29 @@ class SubprocessTransportTests(test_utils.TestCase): transport.close() + def test_subprocess_repr(self): + waiter = asyncio.Future(loop=self.loop) + transport, protocol = self.create_transport(waiter) + transport._process_exited(6) + self.loop.run_until_complete(waiter) + + self.assertEqual( + repr(transport), + "<TestSubprocessTransport pid=-1 returncode=6>" + ) + transport._returncode = None + self.assertEqual( + repr(transport), + "<TestSubprocessTransport pid=-1 running>" + ) + transport._pid = None + transport._returncode = None + self.assertEqual( + repr(transport), + "<TestSubprocessTransport not started>" + ) + transport.close() + class SubprocessMixin: |