Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d361e99

Browse files
authored
bpo-32262: Fix typo in f-string (GH-7016)
Fix typo from commit 6370f34 Signed-off-by: Christian Heimes <[email protected]> <!-- Thanks for your contribution! Please read this comment in its entirety. It's quite important. # Pull Request title It should be in the following format: ``` bpo-NNNN: Summary of the changes made ``` Where: bpo-NNNN refers to the issue number in the https://bugs.python.org. Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue. # Backport Pull Request title If this is a backport PR (PR made against branches other than `master`), please ensure that the PR title is in the following format: ``` [X.Y] <title from the original PR> (GH-NNNN) ``` Where: [X.Y] is the branch name, e.g. [3.6]. GH-NNNN refers to the PR number from `master`. --> <!-- issue-number: bpo-32262 --> https://bugs.python.org/issue32262 <!-- /issue-number -->
1 parent 89a25ce commit d361e99

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lib/asyncio/base_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __repr__(self):
5757
if self._closed:
5858
info.append('closed')
5959
if self._pid is not None:
60-
info.append(f'pid={self.pid}')
60+
info.append(f'pid={self._pid}')
6161
if self._returncode is not None:
6262
info.append(f'returncode={self._returncode}')
6363
elif self._pid is not None:

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def _start(self, *args, **kwargs):
2929
self._proc.stdin = None
3030
self._proc.stdout = None
3131
self._proc.stderr = None
32+
self._proc.pid = -1
3233

3334

3435
class SubprocessTransportTests(test_utils.TestCase):
@@ -73,6 +74,29 @@ def test_proc_exited(self):
7374

7475
transport.close()
7576

77+
def test_subprocess_repr(self):
78+
waiter = asyncio.Future(loop=self.loop)
79+
transport, protocol = self.create_transport(waiter)
80+
transport._process_exited(6)
81+
self.loop.run_until_complete(waiter)
82+
83+
self.assertEqual(
84+
repr(transport),
85+
"<TestSubprocessTransport pid=-1 returncode=6>"
86+
)
87+
transport._returncode = None
88+
self.assertEqual(
89+
repr(transport),
90+
"<TestSubprocessTransport pid=-1 running>"
91+
)
92+
transport._pid = None
93+
transport._returncode = None
94+
self.assertEqual(
95+
repr(transport),
96+
"<TestSubprocessTransport not started>"
97+
)
98+
transport.close()
99+
76100

77101
class SubprocessMixin:
78102

0 commit comments

Comments
 (0)