Skip to content

Commit 1213212

Browse files
agnerspull[bot]
authored andcommitted
[python tests] decode shell output as UTF-8 (#26783)
If tests are run on a platform which is returning special characters (e.g. date with months which contain an umlaut) runnig the test fails: ``` File "/home/sag/projects/project-chip/connectedhomeip/./scripts/tests/run_python_test.py", line 95, in main print(subprocess.check_output(["ls -l"], shell=True).decode('us-ascii')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1553: ordinal not in range(128) ``` Decode the output using UTF-8 by default.
1 parent 4e9db61 commit 1213212

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

scripts/tests/run_java_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def main(app: str, app_args: str, tool_path: str, tool_cluster: str, tool_args:
5555
raise Exception("Failed to remove /tmp/chip* for factory reset.")
5656

5757
print("Contents of test directory: %s" % os.getcwd())
58-
print(subprocess.check_output(["ls -l"], shell=True).decode('us-ascii'))
58+
print(subprocess.check_output(["ls -l"], shell=True).decode('utf-8'))
5959

6060
# Remove native app KVS if that was used
6161
kvs_match = re.search(r"--KVS (?P<kvs_path>[^ ]+)", app_args)

scripts/tests/run_python_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def main(app: str, factoryreset: bool, app_args: str, script: str, script_args:
9292
raise Exception("Failed to remove /tmp/chip* for factory reset.")
9393

9494
print("Contents of test directory: %s" % os.getcwd())
95-
print(subprocess.check_output(["ls -l"], shell=True).decode('us-ascii'))
95+
print(subprocess.check_output(["ls -l"], shell=True).decode('utf-8'))
9696

9797
# Remove native app KVS if that was used
9898
kvs_match = re.search(r"--KVS (?P<kvs_path>[^ ]+)", app_args)

0 commit comments

Comments
 (0)