Mercurial > public > mercurial-scm > hg-stable
diff tests/test-fastannotate-revmap.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 | 0fea133780bf |
children | 9d2b2df2c2ba |
line wrap: on
line diff
--- a/tests/test-fastannotate-revmap.py Sat Oct 05 10:29:34 2019 -0400 +++ b/tests/test-fastannotate-revmap.py Sun Oct 06 09:45:02 2019 -0400 @@ -13,19 +13,23 @@ if pycompat.ispy3: xrange = range + def genhsh(i): return pycompat.bytechr(i) + b'\0' * 19 + def gettemppath(): fd, path = tempfile.mkstemp() os.close(fd) os.unlink(path) return path + def ensure(condition): if not condition: raise RuntimeError('Unexpected') + def testbasicreadwrite(): path = gettemppath() @@ -36,7 +40,19 @@ ensure(rm.hsh2rev(b'\0' * 20) is None) paths = [ - b'', b'a', None, b'b', b'b', b'c', b'c', None, b'a', b'b', b'a', b'a'] + b'', + b'a', + None, + b'b', + b'b', + b'c', + b'c', + None, + b'a', + b'b', + b'a', + b'a', + ] for i in xrange(1, 5): ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i]) == i) @@ -56,8 +72,10 @@ # append without calling save() explicitly for i in xrange(5, 12): - ensure(rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i], - flush=True) == i) + ensure( + rm.append(genhsh(i), sidebranch=(i & 1), path=paths[i], flush=True) + == i + ) # re-load and verify rm = revmap.revmap(path) @@ -85,6 +103,7 @@ except Exception: pass + def testcorruptformat(): path = gettemppath() @@ -127,12 +146,15 @@ os.unlink(path) + def testcopyfrom(): path = gettemppath() rm = revmap.revmap(path) for i in xrange(1, 10): - ensure(rm.append(genhsh(i), - sidebranch=(i & 1), path=(b'%d' % (i // 3))) == i) + ensure( + rm.append(genhsh(i), sidebranch=(i & 1), path=(b'%d' % (i // 3))) + == i + ) rm.flush() # copy rm to rm2 @@ -148,6 +170,7 @@ os.unlink(path) os.unlink(path2) + class fakefctx(object): def __init__(self, node, path=None): self._node = node @@ -159,6 +182,7 @@ def path(self): return self._path + def testcontains(): path = gettemppath() @@ -181,6 +205,7 @@ ensure(fakefctx(genhsh(i), path=(b'%d' % (i // 2))) in rm) ensure(fakefctx(genhsh(i), path=b'a') not in rm) + def testlastnode(): path = gettemppath() ensure(revmap.getlastnode(path) is None) @@ -193,6 +218,7 @@ rm2 = revmap.revmap(path) ensure(rm2.rev2hsh(rm2.maxrev) == hsh) + testbasicreadwrite() testcorruptformat() testcopyfrom()