# HG changeset patch # User Gregory Szorc # Date 2019-11-05 04:57:31 # Node ID e7eb67eab53fc33e4ef1998cdc233869cf2840b1 # Parent a8454e84673641e0132692df2d151a3804e8cc50 tests: write out file using bytes I/O The encoding of sys.stdout varies between Python versions. So using a one-liner to write a file from a Unicode string is not deterministic. This commit writes out the file using bytes I/O to ensure we have exactly the bytes we want in the file. This change fixes a test failure in Python 3.5/3.6. Differential Revision: https://phab.mercurial-scm.org/D7226 diff --git a/tests/test-highlight.t b/tests/test-highlight.t --- a/tests/test-highlight.t +++ b/tests/test-highlight.t @@ -966,7 +966,9 @@ errors encountered $ cd .. $ hg init eucjp $ cd eucjp - $ "$PYTHON" -c 'print("\265\376")' >> eucjp.txt # Japanese kanji "Kyo" + >>> with open('eucjp.txt', 'wb') as fh: + ... # Japanese kanji "Kyo" + ... fh.write(u'\265\376'.encode('utf-8')) and None $ hg ci -Ama adding eucjp.txt $ hgserveget () {