Skip to content

Commit 9736243

Browse files
committed
Configure en_US.UTF-8 locale on Docker, closes #1654
Also unit tests how `shprint()` handles unicode command output.
1 parent 19ca925 commit 9736243

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Dockerfile.py2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ FROM ubuntu:18.04
1919

2020
ENV ANDROID_HOME="/opt/android"
2121

22+
# configure locale
23+
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
24+
locales && \
25+
locale-gen en_US.UTF-8
26+
ENV LANG="en_US.UTF-8" \
27+
LANGUAGE="en_US.UTF-8" \
28+
LC_ALL="en_US.UTF-8"
29+
2230
RUN apt -y update -qq \
2331
&& apt -y install -qq --no-install-recommends curl unzip ca-certificates \
2432
&& apt -y autoremove

Dockerfile.py3

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ FROM ubuntu:18.04
1919

2020
ENV ANDROID_HOME="/opt/android"
2121

22+
# configure locale
23+
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
24+
locales && \
25+
locale-gen en_US.UTF-8
26+
ENV LANG="en_US.UTF-8" \
27+
LANGUAGE="en_US.UTF-8" \
28+
LC_ALL="en_US.UTF-8"
29+
2230
RUN apt -y update -qq \
2331
&& apt -y install -qq --no-install-recommends curl unzip ca-certificates \
2432
&& apt -y autoremove

tests/test_logger.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import unittest
2+
from mock import MagicMock
3+
from pythonforandroid import logger
4+
5+
6+
class TestShprint(unittest.TestCase):
7+
8+
def test_unicode_encode(self):
9+
"""
10+
Makes sure `shprint()` can handle unicode command output.
11+
Running the test with PYTHONIOENCODING=ASCII env would fail, refs:
12+
https://github.com/kivy/python-for-android/issues/1654
13+
"""
14+
expected_command_output = ["foo\xa0bar"]
15+
command = MagicMock()
16+
command.return_value = expected_command_output
17+
output = logger.shprint(command, 'a1', k1='k1')
18+
self.assertEqual(output, expected_command_output)

0 commit comments

Comments
 (0)