changeset 37968:32106c474086

tests: port test-dispatch.py to Python 3 Differential Revision: https://phab.mercurial-scm.org/D3511
author Augie Fackler <augie@google.com>
date Fri, 27 Apr 2018 11:57:15 -0400
parents 40381a88bab4
children b8c2004a8d2b
files contrib/python3-whitelist tests/test-dispatch.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/python3-whitelist	Fri Apr 27 11:55:04 2018 -0400
+++ b/contrib/python3-whitelist	Fri Apr 27 11:57:15 2018 -0400
@@ -105,6 +105,7 @@
 test-dirstate-backup.t
 test-dirstate-nonnormalset.t
 test-dirstate.t
+test-dispatch.py
 test-doctest.py
 test-double-merge.t
 test-drawdag.t
--- a/tests/test-dispatch.py	Fri Apr 27 11:55:04 2018 -0400
+++ b/tests/test-dispatch.py	Fri Apr 27 11:57:15 2018 -0400
@@ -1,18 +1,24 @@
 from __future__ import absolute_import, print_function
 import os
+import sys
 from mercurial import (
     dispatch,
 )
 
+def printb(data, end=b'\n'):
+    out = getattr(sys.stdout, 'buffer', sys.stdout)
+    out.write(data + end)
+    out.flush()
+
 def testdispatch(cmd):
     """Simple wrapper around dispatch.dispatch()
 
     Prints command and result value, but does not handle quoting.
     """
-    print(b"running: %s" % (cmd,))
+    printb(b"running: %s" % (cmd,))
     req = dispatch.request(cmd.split())
     result = dispatch.dispatch(req)
-    print(b"result: %r" % (result,))
+    printb(b"result: %r" % (result,))
 
 testdispatch(b"init test1")
 os.chdir('test1')