tests/test-wireproto.py
changeset 36555 c28de190e20a
parent 36074 2f7290555c96
child 36801 66de4555cefd
--- a/tests/test-wireproto.py	Fri Mar 02 04:47:56 2018 +0530
+++ b/tests/test-wireproto.py	Fri Mar 02 04:49:08 2018 +0530
@@ -2,6 +2,7 @@
 
 from mercurial import (
     error,
+    pycompat,
     util,
     wireproto,
     wireprototypes,
@@ -13,7 +14,7 @@
         self.args = args
     def getargs(self, spec):
         args = self.args
-        args.setdefault('*', {})
+        args.setdefault(b'*', {})
         names = spec.split()
         return [args[n] for n in names]
 
@@ -26,7 +27,7 @@
         return self.serverrepo.ui
 
     def url(self):
-        return 'test'
+        return b'test'
 
     def local(self):
         return None
@@ -41,9 +42,10 @@
         pass
 
     def capabilities(self):
-        return ['batch']
+        return [b'batch']
 
     def _call(self, cmd, **args):
+        args = pycompat.byteskwargs(args)
         res = wireproto.dispatch(self.serverrepo, proto(args), cmd)
         if isinstance(res, wireprototypes.bytesresponse):
             return res.data
@@ -58,31 +60,31 @@
     @wireproto.batchable
     def greet(self, name):
         f = wireproto.future()
-        yield {'name': mangle(name)}, f
+        yield {b'name': mangle(name)}, f
         yield unmangle(f.value)
 
 class serverrepo(object):
     def greet(self, name):
-        return "Hello, " + name
+        return b"Hello, " + name
 
     def filtered(self, name):
         return self
 
 def mangle(s):
-    return ''.join(chr(ord(c) + 1) for c in s)
+    return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s))
 def unmangle(s):
-    return ''.join(chr(ord(c) - 1) for c in s)
+    return b''.join(pycompat.bytechr(ord(c) - 1) for c in pycompat.bytestr(s))
 
 def greet(repo, proto, name):
     return mangle(repo.greet(unmangle(name)))
 
-wireproto.commands['greet'] = (greet, 'name',)
+wireproto.commands[b'greet'] = (greet, b'name',)
 
 srv = serverrepo()
 clt = clientpeer(srv)
 
-print(clt.greet("Foobar"))
+print(clt.greet(b"Foobar"))
 b = clt.iterbatch()
-map(b.greet, ('Fo, =;:<o', 'Bar'))
+list(map(b.greet, (b'Fo, =;:<o', b'Bar')))
 b.submit()
 print([r for r in b.results()])