tests: port test-dispatch.py to Python 3
Differential Revision: https://phab.mercurial-scm.org/D3511
--- 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')