D8341: tests: force \n newlines when writing to sys.stdout

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D8341: tests: force \n newlines when writing to sys.stdout

valentin.gatienbaron (Valentin Gatien-Baron)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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!

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8341

AFFECTED FILES
  tests/filtertraceback.py

CHANGE DETAILS

diff --git a/tests/filtertraceback.py b/tests/filtertraceback.py
--- a/tests/filtertraceback.py
+++ b/tests/filtertraceback.py
@@ -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:



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D8341: tests: force \n newlines when writing to sys.stdout

valentin.gatienbaron (Valentin Gatien-Baron)
Closed by commit rHGd359f0d1a3d3: tests: force \n newlines when writing to sys.stdout (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8341?vs=20914&id=20951

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8341/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8341

AFFECTED FILES
  tests/filtertraceback.py

CHANGE DETAILS

diff --git a/tests/filtertraceback.py b/tests/filtertraceback.py
--- a/tests/filtertraceback.py
+++ b/tests/filtertraceback.py
@@ -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:



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel