Skip to content

Commit

Permalink
Stop assuming getpreferredencoding() is UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
oremanj committed May 6, 2019
1 parent 81cb2e1 commit 972cf72
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tricycle/_tests/test_streams.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest # type: ignore
import locale
import random
import sys

Expand Down Expand Up @@ -174,6 +175,8 @@ async def test_text_receive(autojump_clock: trio.testing.MockClock) -> None:
b"That \xf0\x9f\xa6\x8a is still jumping.\r" # fox emoji
)

assert TextReceiveStream(None).encoding == locale.getpreferredencoding(False)

newline: Optional[str]
for newline in ("\r", "\n", "\r\n", "", "jump", None):
output_str = test_input.decode("utf-8")
Expand Down Expand Up @@ -203,7 +206,7 @@ async def make_streams_with_hook(

send_stream, receive_stream_raw = trio.testing.memory_stream_one_way_pair()
receive_stream = TextReceiveStream(
receive_stream_raw, chunk_size=8, newline=newline
receive_stream_raw, "UTF-8", chunk_size=8, newline=newline
)
if hook is not None:
send_stream.send_all_hook = partial(
Expand Down

0 comments on commit 972cf72

Please sign in to comment.