Skip to content

Commit 38a3838

Browse files
committed
!squash mypy for subcommand
1 parent c5bae26 commit 38a3838

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: tests/_internal/subprocess/test_SubprocessCommand.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def test_Popen_mock(
168168
attrs = {"communicate.return_value": ("output", "error"), "returncode": 1}
169169
process_mock.configure_mock(**attrs)
170170
mock_subprocess_popen.return_value = process_mock
171-
cmd = SubprocessCommand(*args, cwd=tmp_path, **kwargs)
171+
kwargs["cwd"] = tmp_path
172+
cmd = SubprocessCommand(*args, **kwargs)
172173
response = cmd.Popen(**run_kwargs)
173174

174175
assert response.returncode == 1
@@ -194,7 +195,8 @@ def test_Popen_git_mock(
194195
attrs = {"communicate.return_value": ("output", "error"), "returncode": 1}
195196
process_mock.configure_mock(**attrs)
196197
mock_subprocess_popen.return_value = process_mock
197-
cmd = SubprocessCommand(*args, cwd=tmp_path, **kwargs)
198+
kwargs["cwd"] = tmp_path
199+
cmd = SubprocessCommand(*args, **kwargs)
198200
response = cmd.Popen(**run_kwargs)
199201

200202
stdout, stderr = response.communicate()
@@ -262,9 +264,10 @@ def test_CaptureStderrMixin(
262264
)
263265
response = cmd.Popen()
264266
while response.poll() is None:
265-
line = response.stderr.readline().decode("utf-8").strip()
266-
if line:
267-
assert line.startswith("[")
267+
if response.stderr is not None:
268+
line = response.stderr.readline().decode("utf-8").strip()
269+
if line:
270+
assert line.startswith("[")
268271
assert response.returncode == 0
269272

270273

@@ -289,8 +292,9 @@ def test_CaptureStderrMixin_error(
289292
)
290293
response = cmd.Popen()
291294
while response.poll() is None:
292-
line = response.stderr.readline().decode("utf-8").strip()
293-
if line:
294-
assert line.startswith("[") or line == "FATAL"
295+
if response.stderr is not None:
296+
line = response.stderr.readline().decode("utf-8").strip()
297+
if line:
298+
assert line.startswith("[") or line == "FATAL"
295299

296300
assert response.returncode == 1

0 commit comments

Comments
 (0)