changeset 44654:d359f0d1a3d3

tests: force \n newlines when writing to sys.stdout Without this, Python 3 on Windows inserts some \r that aren't present in the input, causing test-http-bad-server.t to fail. After this change, the test passes on Python 3 on Windows! Differential Revision: https://phab.mercurial-scm.org/D8341
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 29 Mar 2020 13:51:26 -0700
parents 02fa5392bab6
children 47e6ec977555
files tests/filtertraceback.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/filtertraceback.py	Sun Mar 29 13:06:59 2020 -0700
+++ b/tests/filtertraceback.py	Sun Mar 29 13:51:26 2020 -0700
@@ -4,8 +4,19 @@
 
 from __future__ import absolute_import, print_function
 
+import io
 import sys
 
+if sys.version_info[0] >= 3:
+    # Prevent \r from being inserted on Windows.
+    sys.stdout = io.TextIOWrapper(
+        sys.stdout.buffer,
+        sys.stdout.encoding,
+        sys.stdout.errors,
+        newline="\n",
+        line_buffering=sys.stdout.line_buffering,
+    )
+
 state = 'none'
 
 for line in sys.stdin: