Mercurial > public > mercurial-scm > hg-stable
diff tests/test-wireproto.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | d6569f1e9b37 |
children | c424ff4807e6 |
line wrap: on
line diff
--- a/tests/test-wireproto.py Sat Oct 05 10:29:34 2019 -0400 +++ b/tests/test-wireproto.py Sun Oct 06 09:45:02 2019 -0400 @@ -11,11 +11,11 @@ wireprotov1peer, wireprotov1server, ) -from mercurial.utils import ( - stringutil, -) +from mercurial.utils import stringutil + stringio = util.stringio + class proto(object): def __init__(self, args): self.args = args @@ -30,11 +30,13 @@ def checkperm(self, perm): pass + wireprototypes.TRANSPORTS['dummyproto'] = { 'transport': 'dummy', 'version': 1, } + class clientpeer(wireprotov1peer.wirepeer): def __init__(self, serverrepo, ui): self.serverrepo = serverrepo @@ -77,6 +79,7 @@ yield {b'name': mangle(name)}, f yield unmangle(f.value) + class serverrepo(object): def __init__(self, ui): self.ui = ui @@ -87,29 +90,37 @@ def filtered(self, name): return self + def mangle(s): return b''.join(pycompat.bytechr(ord(c) + 1) for c in pycompat.bytestr(s)) + + def unmangle(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))) + wireprotov1server.commands[b'greet'] = (greet, b'name') srv = serverrepo(uimod.ui()) clt = clientpeer(srv, uimod.ui()) + 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'}) -printb(stringutil.pprint([f.result() for f in (fgreet1, fgreet2)], - bprefix=True)) +printb( + stringutil.pprint([f.result() for f in (fgreet1, fgreet2)], bprefix=True) +)