Skip to content
Myr

don't claim empty stderr wasn't captured separately

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Julian Berman · committed by David Lord · parent e0ad5a6 · Browse files · 3 files+21 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+21 added−3 removed

  • tests:+12 added−0 removed
  • other:+9 added−3 removed

3 files+21 added−3 removed

modified:click/testing.py+6 added-3 removed
77 unmodified lines
78 #: The runner that created the result79 self.runner = runner80 #: The standard output as bytes.81 self.stdout_bytes = stdout_bytes82 #: The standard error as bytes, or False(y) if not available82 #: The standard error as bytes, or None if not available83 self.stderr_bytes = stderr_bytes84 #: The exit code as integer.85 self.exit_code = exit_code86 #: The exception that happened if one did.
14 unmodified lines
101102 @property103 def stderr(self):104 """The standard error as unicode string."""105 if not self.stderr_bytes:105 if self.stderr_bytes is None:106 raise ValueError("stderr not separately captured")107 return self.stderr_bytes.decode(self.runner.charset, 'replace') \108 .replace('\r\n', '\n')109
236 unmodified lines
346 exc_info = sys.exc_info()347 finally:348 sys.stdout.flush()349 stdout = outstreams[0].getvalue()350 if self.mix_stderr:351 stderr = None352 else:350 stderr = outstreams[1] and outstreams[1].getvalue()353 stderr = outstreams[1].getvalue()354355 return Result(runner=self,356 stdout_bytes=stdout,357 stderr_bytes=stderr,
20 unmodified lines
modified:tests/test_testing.py+12 added
255 unmodified lines
256257 with pytest.raises(ValueError):258 result_mix.stderr259260 @click.command()261 def cli_empty_stderr():262 click.echo("stdout")263264 runner = CliRunner(mix_stderr=False)265266 result = runner.invoke(cli_empty_stderr)267268 assert result.output == 'stdout\n'269 assert result.stdout == 'stdout\n'270 assert result.stderr == ''271272273@pytest.mark.parametrize('args, expected_output', [274 (None, 'bar\n'),275 ([], 'bar\n'),276 ('', 'bar\n'),
25 unmodified lines
modified:CHANGES.rst+3 added
29 unmodified lines
30- It is once again possible to call ``next(bar)`` on an active31 progress bar instance. :issue:`1125`32- ``open_file`` with ``atomic=True`` retains permissions of existing33 files and respects the current umask for new files. :issue:`1376`34- When using the test ``CliRunner`` with ``mix_stderr=False``, if35 ``result.stderr`` is empty it will not raise a ``ValueError``.36 :issue:`1193`373839Version 7.040-----------
540 unmodified lines