mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-14 13:05:09 +00:00
fix(console): write UTF-8 to redirected streams on Windows
This commit is contained in:
@@ -2,12 +2,16 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from unshackle.core import __version__
|
||||
from unshackle.core.__main__ import main
|
||||
from unshackle.core.__main__ import main, print_banner
|
||||
from unshackle.core.config import config
|
||||
from unshackle.core.console import force_utf8_streams
|
||||
|
||||
|
||||
@pytest.mark.parametrize("args", [["--help"], ["env", "--help"]])
|
||||
@@ -19,3 +23,13 @@ def test_help_prints_the_banner_once(monkeypatch: pytest.MonkeyPatch, args: list
|
||||
assert result.exit_code == 0, result.output
|
||||
assert result.output.count(f"v {__version__}") == 1
|
||||
assert "Usage:" in result.output
|
||||
|
||||
|
||||
def test_banner_prints_to_a_legacy_code_page_stream(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
buffer = io.BytesIO()
|
||||
monkeypatch.setattr(sys, "stdout", io.TextIOWrapper(buffer, encoding="cp1252"))
|
||||
|
||||
force_utf8_streams()
|
||||
print_banner()
|
||||
|
||||
assert "▄".encode() in buffer.getvalue()
|
||||
|
||||
Reference in New Issue
Block a user