Patchwork D3510: tests: port test-wireproto.py to Python 3

login
register
mail settings
Submitter phabricator
Date May 10, 2018, 10:42 a.m.
Message ID <2cc440f0c3bdadf2f0690126fcc42317@localhost.localdomain>
Download mbox | patch
Permalink /patch/31444/
State Not Applicable
Headers show

Comments

phabricator - May 10, 2018, 10:42 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG40381a88bab4: tests: port test-wireproto.py to Python 3 (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3510?vs=8578&id=8604

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-wireproto.py
  tests/test-wireproto.py.out

CHANGE DETAILS




To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-wireproto.py.out b/tests/test-wireproto.py.out
--- a/tests/test-wireproto.py.out
+++ b/tests/test-wireproto.py.out
@@ -1,2 +1,2 @@ 
 Hello, Foobar
-['Hello, Fo, =;:<o', 'Hello, Bar']
+[b'Hello, Fo, =;:<o', b'Hello, Bar']
diff --git a/tests/test-wireproto.py b/tests/test-wireproto.py
--- a/tests/test-wireproto.py
+++ b/tests/test-wireproto.py
@@ -1,5 +1,7 @@ 
 from __future__ import absolute_import, print_function
 
+import sys
+
 from mercurial import (
     error,
     pycompat,
@@ -9,6 +11,9 @@ 
     wireprotov1peer,
     wireprotov1server,
 )
+from mercurial.utils import (
+    stringutil,
+)
 stringio = util.stringio
 
 class proto(object):
@@ -92,10 +97,15 @@ 
 srv = serverrepo()
 clt = clientpeer(srv, uimod.ui())
 
-print(clt.greet(b"Foobar"))
+def printb(data, end=b'\n'):
+    out = getattr(sys.stdout, 'buffer', sys.stdout)
+    out.write(data + end)
+    out.flush()
+
+printb(clt.greet(b"Foobar"))
 
 with clt.commandexecutor() as e:
     fgreet1 = e.callcommand(b'greet', {b'name': b'Fo, =;:<o'})
     fgreet2 = e.callcommand(b'greet', {b'name': b'Bar'})
 
-print([f.result() for f in (fgreet1, fgreet2)])
+printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)]))
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -471,5 +471,6 @@ 
 test-wireproto-clientreactor.py
 test-wireproto-framing.py
 test-wireproto-serverreactor.py
+test-wireproto.py
 test-wsgirequest.py
 test-xdg.t