diff options
| author | Charles Brunet <charles.brunet@optelgroup.com> | 2024-02-28 11:58:29 -0500 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-03-01 12:09:22 -0800 |
| commit | 4ed6d75d962b3d43a9f7e8f5154e48d0bef01cc9 (patch) | |
| tree | ba079cd5c44c74e6c8882db3a6dba36f865c04ff | |
| parent | c67a6e1d7cdb7883621eaceda9af08b9eecf34a8 (diff) | |
| download | meson-4ed6d75d962b3d43a9f7e8f5154e48d0bef01cc9.tar.gz | |
Set PYTHONIOENCODING when running tests
For instance, on Windows, if the terminal is in cp65001, the subprocess
output is not encoded correctly and it results in error when running
unit test.
| -rw-r--r-- | unittests/allplatformstests.py | 2 | ||||
| -rw-r--r-- | unittests/baseplatformtests.py | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index bfd0b1856..777f2f92a 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -471,7 +471,7 @@ class AllPlatformTests(BasePlatformTests): # Ensure command output and JSON / text logs are not mangled. raw_output_sample = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b' assert raw_output_sample in tests_command_output - text_log = Path(self.logdir, 'testlog.txt').read_text() + text_log = Path(self.logdir, 'testlog.txt').read_text(encoding='utf-8') assert raw_output_sample in text_log json_log = json.loads(Path(self.logdir, 'testlog.json').read_bytes()) assert raw_output_sample in json_log['stdout'] diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index ec3f18908..6125ed933 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -85,6 +85,7 @@ class BasePlatformTests(TestCase): # XCode backend is untested with unit tests, help welcome! self.no_rebuild_stdout = [f'UNKNOWN BACKEND {self.backend.name!r}'] os.environ['COLUMNS'] = '80' + os.environ['PYTHONIOENCODING'] = 'utf8' self.builddirs = [] self.new_builddir() |
