# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1519946348 -19800 # Node ID c28de190e20ab1c6b93a33ee0c6627f7e5030ca5 # Parent 06f59bdde62695909bcf8d4f0e55944a98967daa py3: port tests/test-wireproto.py to Python 3 Differential Revision: https://phab.mercurial-scm.org/D2534 diff -r 06f59bdde626 -r c28de190e20a tests/test-wireproto.py --- 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, =;: