[RFC PATCH 01/13] tests: specify UTF-8 encoding when opening files in text mode
Adrian Neftali Sanchez <[email protected]>
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <[email protected]> |
Python 3 open() inherits the locale encoding by default; on Windows that is typically cp1252 rather than UTF-8. Explicitly passing encoding="utf-8" makes the test portable across platforms. Signed-off-by: Adrian Neftali Sanchez <[email protected]> --- src/tests/test___init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test___init__.py b/src/tests/test___init__.py index 3c4c2d0..5544978 100644 --- a/src/tests/test___init__.py +++ b/src/tests/test___init__.py @@ -75,7 +75,7 @@ def test_save_git_am_mbox( dest = os.path.join(tmp_path, 'out') with open(dest, 'wb') as fh: b4.save_git_am_mbox(msgs, fh) - with open(dest, 'r') as fh: + with open(dest, 'r', encoding='utf-8') as fh: res = fh.read() assert re.search(regex, res, flags=flags) -- 2.45.0.windows.1