--- a/tests/test-check-interfaces.py Sat Oct 05 10:29:34 2019 -0400
+++ b/tests/test-check-interfaces.py Sun Oct 06 09:45:02 2019 -0400
@@ -3,6 +3,7 @@
from __future__ import absolute_import, print_function
from mercurial import encoding
+
encoding.environ[b'HGREALINTERFACES'] = b'1'
import os
@@ -10,20 +11,17 @@
import sys
# Only run if tests are run in a repo
-if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'],
- 'test-repo']):
+if subprocess.call(
+ ['python', '%s/hghave' % os.environ['TESTDIR'], 'test-repo']
+):
sys.exit(80)
from mercurial.interfaces import (
dirstate as intdirstate,
repository,
)
-from mercurial.thirdparty.zope import (
- interface as zi,
-)
-from mercurial.thirdparty.zope.interface import (
- verify as ziverify,
-)
+from mercurial.thirdparty.zope import interface as zi
+from mercurial.thirdparty.zope.interface import verify as ziverify
from mercurial import (
bundlerepo,
dirstate,
@@ -49,8 +47,10 @@
sys.path[0:0] = [testdir]
import simplestorerepo
+
del sys.path[0]
+
def checkzobject(o, allowextra=False):
"""Verify an object with a zope interface."""
ifaces = zi.providedBy(o)
@@ -75,35 +75,45 @@
public = {a for a in dir(o) if not a.startswith('_')}
for attr in sorted(public - allowed):
- print('public attribute not declared in interfaces: %s.%s' % (
- o.__class__.__name__, attr))
+ print(
+ 'public attribute not declared in interfaces: %s.%s'
+ % (o.__class__.__name__, attr)
+ )
+
# Facilitates testing localpeer.
class dummyrepo(object):
def __init__(self):
self.ui = uimod.ui()
+
def filtered(self, name):
pass
+
def _restrictcapabilities(self, caps):
pass
+
class dummyopener(object):
handlers = []
+
# Facilitates testing sshpeer without requiring a server.
class badpeer(httppeer.httppeer):
def __init__(self):
- super(badpeer, self).__init__(None, None, None, dummyopener(), None,
- None)
+ super(badpeer, self).__init__(
+ None, None, None, dummyopener(), None, None
+ )
self.badattribute = True
def badmethod(self):
pass
+
class dummypipe(object):
def close(self):
pass
+
def main():
ui = uimod.ui()
# Needed so we can open a local repo with obsstore without a warning.
@@ -117,25 +127,44 @@
ziverify.verifyClass(repository.ipeerv2, httppeer.httpv2peer)
checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None))
- ziverify.verifyClass(repository.ipeerbase,
- localrepo.localpeer)
+ ziverify.verifyClass(repository.ipeerbase, localrepo.localpeer)
checkzobject(localrepo.localpeer(dummyrepo()))
- ziverify.verifyClass(repository.ipeercommandexecutor,
- localrepo.localcommandexecutor)
+ ziverify.verifyClass(
+ repository.ipeercommandexecutor, localrepo.localcommandexecutor
+ )
checkzobject(localrepo.localcommandexecutor(None))
- ziverify.verifyClass(repository.ipeercommandexecutor,
- wireprotov1peer.peerexecutor)
+ ziverify.verifyClass(
+ repository.ipeercommandexecutor, wireprotov1peer.peerexecutor
+ )
checkzobject(wireprotov1peer.peerexecutor(None))
ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv1peer)
- checkzobject(sshpeer.sshv1peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
- dummypipe(), None, None))
+ checkzobject(
+ sshpeer.sshv1peer(
+ ui,
+ b'ssh://localhost/foo',
+ b'',
+ dummypipe(),
+ dummypipe(),
+ None,
+ None,
+ )
+ )
ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv2peer)
- checkzobject(sshpeer.sshv2peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
- dummypipe(), None, None))
+ checkzobject(
+ sshpeer.sshv2peer(
+ ui,
+ b'ssh://localhost/foo',
+ b'',
+ dummypipe(),
+ dummypipe(),
+ None,
+ None,
+ )
+ )
ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
checkzobject(bundlerepo.bundlepeer(dummyrepo()))
@@ -146,21 +175,29 @@
ziverify.verifyClass(repository.ipeerbase, unionrepo.unionpeer)
checkzobject(unionrepo.unionpeer(dummyrepo()))
- ziverify.verifyClass(repository.ilocalrepositorymain,
- localrepo.localrepository)
- ziverify.verifyClass(repository.ilocalrepositoryfilestorage,
- localrepo.revlogfilestorage)
+ ziverify.verifyClass(
+ repository.ilocalrepositorymain, localrepo.localrepository
+ )
+ ziverify.verifyClass(
+ repository.ilocalrepositoryfilestorage, localrepo.revlogfilestorage
+ )
repo = localrepo.makelocalrepository(ui, rootdir)
checkzobject(repo)
- ziverify.verifyClass(wireprototypes.baseprotocolhandler,
- wireprotoserver.sshv1protocolhandler)
- ziverify.verifyClass(wireprototypes.baseprotocolhandler,
- wireprotoserver.sshv2protocolhandler)
- ziverify.verifyClass(wireprototypes.baseprotocolhandler,
- wireprotoserver.httpv1protocolhandler)
- ziverify.verifyClass(wireprototypes.baseprotocolhandler,
- wireprotov2server.httpv2protocolhandler)
+ ziverify.verifyClass(
+ wireprototypes.baseprotocolhandler, wireprotoserver.sshv1protocolhandler
+ )
+ ziverify.verifyClass(
+ wireprototypes.baseprotocolhandler, wireprotoserver.sshv2protocolhandler
+ )
+ ziverify.verifyClass(
+ wireprototypes.baseprotocolhandler,
+ wireprotoserver.httpv1protocolhandler,
+ )
+ ziverify.verifyClass(
+ wireprototypes.baseprotocolhandler,
+ wireprotov2server.httpv2protocolhandler,
+ )
sshv1 = wireprotoserver.sshv1protocolhandler(None, None, None)
checkzobject(sshv1)
@@ -174,22 +211,28 @@
ziverify.verifyClass(repository.ifilestorage, filelog.filelog)
ziverify.verifyClass(repository.imanifestdict, manifest.manifestdict)
- ziverify.verifyClass(repository.imanifestrevisionstored,
- manifest.manifestctx)
- ziverify.verifyClass(repository.imanifestrevisionwritable,
- manifest.memmanifestctx)
- ziverify.verifyClass(repository.imanifestrevisionstored,
- manifest.treemanifestctx)
- ziverify.verifyClass(repository.imanifestrevisionwritable,
- manifest.memtreemanifestctx)
+ ziverify.verifyClass(
+ repository.imanifestrevisionstored, manifest.manifestctx
+ )
+ ziverify.verifyClass(
+ repository.imanifestrevisionwritable, manifest.memmanifestctx
+ )
+ ziverify.verifyClass(
+ repository.imanifestrevisionstored, manifest.treemanifestctx
+ )
+ ziverify.verifyClass(
+ repository.imanifestrevisionwritable, manifest.memtreemanifestctx
+ )
ziverify.verifyClass(repository.imanifestlog, manifest.manifestlog)
ziverify.verifyClass(repository.imanifeststorage, manifest.manifestrevlog)
- ziverify.verifyClass(repository.irevisiondelta,
- simplestorerepo.simplestorerevisiondelta)
+ ziverify.verifyClass(
+ repository.irevisiondelta, simplestorerepo.simplestorerevisiondelta
+ )
ziverify.verifyClass(repository.ifilestorage, simplestorerepo.filestorage)
- ziverify.verifyClass(repository.iverifyproblem,
- simplestorerepo.simplefilestoreproblem)
+ ziverify.verifyClass(
+ repository.iverifyproblem, simplestorerepo.simplefilestoreproblem
+ )
ziverify.verifyClass(intdirstate.idirstate, dirstate.dirstate)
@@ -198,8 +241,9 @@
checkzobject(fl, allowextra=True)
# Conforms to imanifestlog.
- ml = manifest.manifestlog(vfs, repo, manifest.manifestrevlog(repo.svfs),
- repo.narrowmatch())
+ ml = manifest.manifestlog(
+ vfs, repo, manifest.manifestrevlog(repo.svfs), repo.narrowmatch()
+ )
checkzobject(ml)
checkzobject(repo.manifestlog)
@@ -217,8 +261,7 @@
mrl = manifest.manifestrevlog(vfs)
checkzobject(mrl)
- ziverify.verifyClass(repository.irevisiondelta,
- revlog.revlogrevisiondelta)
+ ziverify.verifyClass(repository.irevisiondelta, revlog.revlogrevisiondelta)
rd = revlog.revlogrevisiondelta(
node=b'',
@@ -229,11 +272,12 @@
flags=b'',
baserevisionsize=None,
revision=b'',
- delta=None)
+ delta=None,
+ )
checkzobject(rd)
- ziverify.verifyClass(repository.iverifyproblem,
- revlog.revlogproblem)
+ ziverify.verifyClass(repository.iverifyproblem, revlog.revlogproblem)
checkzobject(revlog.revlogproblem())
+
main()