tests.test_output moduleΒΆ

tests.test_output.UNENCODABLE_ON_CP1252 = ('βœ“', '✘', 'β•­', '─')ΒΆ

Glyphs Click Extra prints that a legacy Windows code page cannot encode: the two status marks, and two characters of a rounded table border.

class tests.test_output.FakeStream(encoding, *, refuse=False)[source]ΒΆ

Bases: object

A stand-in for a standard stream, recording what it was reconfigured to.

The real streams of a test run already speak UTF-8, so the legacy path is never taken through them.

reconfigured: dict[str, str]ΒΆ
reconfigure(**kwargs)[source]ΒΆ
Return type:

None

tests.test_output.test_stdout_sentinel()[source]ΒΆ
Return type:

None

tests.test_output.test_is_stdout()[source]ΒΆ
Return type:

None

tests.test_output.test_prep_path_creates_parents_and_writes_utf8(tmp_path)[source]ΒΆ
Return type:

None

tests.test_output.test_prep_path_stdout(capsys)[source]ΒΆ
Return type:

None

tests.test_output.test_prep_path_reopens_the_process_stdout_as_utf8(monkeypatch, tmp_path)[source]ΒΆ

The stdout of the process itself is opened again on its descriptor, as UTF-8.

Its own cp1252 encoding cannot carry the glyphs. Closing the stream returned leaves that stdout open.

Return type:

None

tests.test_output.test_prep_path_returns_a_process_stdout_without_descriptor(monkeypatch)[source]ΒΆ

A stdout of the process with no file descriptor is returned as-is.

Return type:

None

tests.test_output.test_prep_path_stdout_reaches_the_runner_capture(capture)[source]ΒΆ

A command writing to - prints into the capture of Click’s test runner.

Under capture="fd", sys.stdout.fileno() returns a copy of the original stdout descriptor, so a stream opened on it writes past the capture.

Return type:

None

tests.test_output.test_legacy_stream_is_switched_to_utf8(monkeypatch, encoding)[source]ΒΆ

A stream unable to carry the glyphs is reconfigured to UTF-8.

So is a stream reporting an encoding Python does not know.

Return type:

None

tests.test_output.test_utf8_stream_is_left_alone(monkeypatch, encoding)[source]ΒΆ

A stream already speaking UTF-8 is never reconfigured, whatever its spelling.

Return type:

None

tests.test_output.test_a_refusing_stream_never_raises(monkeypatch)[source]ΒΆ

A stream refusing reconfiguration is left as the platform made it.

Return type:

None

tests.test_output.test_a_stream_without_reconfigure_is_skipped(monkeypatch)[source]ΒΆ

A stream object without reconfigure(), like a capture, raises nothing.

Return type:

None

tests.test_output.test_command_prints_glyphs_to_a_legacy_stream(monkeypatch)[source]ΒΆ

A command prints a glyph to a cp1252 stream instead of crashing on it.

The streams keep \n as written: the default would turn it into \r\n on Windows.

Return type:

None