Skip to content
Myr

test runner opens stderr with backslashreplace

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

authored by David Lord · committed by David Lord · parent c454226 · Browse files · 3 files+26 added−4 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+26 added−4 removed

  • tests:+12 added−0 removed
  • other:+14 added−4 removed

3 files+26 added−4 removed

modified:src/click/testing.py+12 added-4 removed
176 unmodified lines
177 prompt functionality).178179 This is automatically done in the :meth:`invoke` method.180181 .. versionadded:: 4.0182 The ``color`` parameter was added.183181 :param input: the input stream to put into sys.stdin.182 :param env: the environment overrides as dictionary.183 :param color: whether the output should contain color codes. The184 application can still override this explicitly.185186 .. versionchanged:: 8.0187 ``stderr`` is opened with ``errors="backslashreplace"``188 instead of the default ``"strict"``.189190 .. versionchanged:: 4.0191 Added the ``color`` parameter.192 """193 input = make_input_stream(input, self.charset)194195 old_stdin = sys.stdin
21 unmodified lines
217 sys.stderr = sys.stdout218 else:219 bytes_error = io.BytesIO()220 sys.stderr = _NamedTextIOWrapper(217 bytes_error, encoding=self.charset, name="<stderr>", mode="w"221 bytes_error,222 encoding=self.charset,223 name="<stderr>",224 mode="w",225 errors="backslashreplace",226 )227228 def visible_input(prompt=None):229 sys.stdout.write(prompt or "")
189 unmodified lines
modified:tests/test_testing.py+12 added
332 unmodified lines
333 assert os.path.exists(d)334335 assert os.path.exists(d)336 os.rmdir(d)337338339def test_isolation_stderr_errors():340 """Writing to stderr should escape invalid characters instead of341 raising a UnicodeEncodeError.342 """343 runner = CliRunner(mix_stderr=False)344345 with runner.isolation() as (_, err):346 click.echo("\udce2", err=True, nl=False)347348 assert err.getvalue() == b"\\udce2"
modified:CHANGES.rst+2 added
197 unmodified lines
198- When taking arguments from ``sys.argv`` on Windows, glob patterns,199 user dir, and env vars are expanded. :issue:`1096`200- Marked messages shown by the CLI with ``gettext()`` to allow201 applications to translate Click's built-in strings. :issue:`303`202- Writing invalid characters to ``stderr`` when using the test runner203 does not raise a ``UnicodeEncodeError``. :issue:`848`204205206Version 7.1.2207-------------
635 unmodified lines