Patchwork D8342: tests: prevent printing \r to stdout

login
register
mail settings
Submitter phabricator
Date March 30, 2020, 1:30 a.m.
Message ID <differential-rev-PHID-DREV-7dc4esxle3e5uubbvuv5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45943/
State Superseded
Headers show

Comments

phabricator - March 30, 2020, 1:30 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Like we've done in other recent commits, we need to change
  sys.stdout on Python 3 to not use os.linesep so output is
  consistent on Python 3 on Windows.
  
  With this change, test-notify.t now passes on Python 3 on Windows!

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-notify.t

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-notify.t b/tests/test-notify.t
--- a/tests/test-notify.t
+++ b/tests/test-notify.t
@@ -1,7 +1,16 @@ 
   $ cat > $TESTTMP/filter.py <<EOF
   > from __future__ import absolute_import, print_function
+  > import io
   > import re
   > import sys
+  > if sys.version_info[0] >= 3:
+  >     sys.stdout = io.TextIOWrapper(
+  >         sys.stdout.buffer,
+  >         sys.stdout.encoding,
+  >         sys.stdout.errors,
+  >         newline="\n",
+  >         line_buffering=sys.stdout.line_buffering,
+  >     )
   > print(re.sub("\n[ \t]", " ", sys.stdin.read()), end="")
   > EOF