|
14 | 14 | format_command_args,
|
15 | 15 | make_command,
|
16 | 16 | make_subprocess_output_error,
|
| 17 | + subprocess_logger, |
17 | 18 | )
|
18 | 19 |
|
19 | 20 |
|
@@ -154,6 +155,35 @@ def test_make_subprocess_output_error__non_ascii_line():
|
154 | 155 | assert actual == expected, u'actual: {}'.format(actual)
|
155 | 156 |
|
156 | 157 |
|
| 158 | +@pytest.mark.parametrize( |
| 159 | + ('stdout_only', 'expected'), |
| 160 | + [ |
| 161 | + (True, ("out\n", "out\r\n")), |
| 162 | + (False, ("out\nerr\n", "out\r\nerr\r\n", "err\nout\n", "err\r\nout\r\n")), |
| 163 | + ], |
| 164 | +) |
| 165 | +def test_call_subprocess_stdout_only(capfd, monkeypatch, stdout_only, expected): |
| 166 | + log = [] |
| 167 | + monkeypatch.setattr(subprocess_logger, "debug", lambda *args: log.append(args[0])) |
| 168 | + out = call_subprocess( |
| 169 | + [ |
| 170 | + sys.executable, |
| 171 | + "-c", |
| 172 | + "import sys; " |
| 173 | + "sys.stdout.write('out\\n'); " |
| 174 | + "sys.stderr.write('err\\n')" |
| 175 | + ], |
| 176 | + stdout_only=stdout_only, |
| 177 | + ) |
| 178 | + assert out in expected |
| 179 | + captured = capfd.readouterr() |
| 180 | + assert captured.err == "" |
| 181 | + assert ( |
| 182 | + log == ["Running command %s", "out", "err"] |
| 183 | + or log == ["Running command %s", "err", "out"] |
| 184 | + ) |
| 185 | + |
| 186 | + |
157 | 187 | class FakeSpinner(SpinnerInterface):
|
158 | 188 |
|
159 | 189 | def __init__(self):
|
|
0 commit comments