changeset 52443:0cc50d9ac6b0

tests: drop references to the vendored copy of `zope` The `test-check-interfaces.py` test has mostly been a no-op since ef7d85089952. Somehow, checks are still done on mere imports, as these errors were seen when subclassing `Protocol` and adding the `self` argument to the repository interfaces. So just get rid of it. --- /builds/mercurial-ci/tests/test-check-interfaces.py.out +++ /builds/mercurial-ci/tests/test-check-interfaces.py.err @@ -0,0 +1,16 @@ +Traceback (most recent call last): + File "/builds/mercurial-ci/tests/test-check-interfaces.py", line 12, in <module> + from mercurial.interfaces import ( + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/interfaces/repository.py", line 401, in <module> + @interfaceutil.implementer(ipeerbase) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 388, in __call__ + classImplements(ob, *self.interfaces) + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 327, in classImplements + spec.declared += tuple(_normalizeargs(interfaces)) + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 910, in _normalizeargs + _normalizeargs(v, output) + File "/tmp/hgtests.hl7bqyl0/install/lib/python/mercurial/thirdparty/zope/interface/declarations.py", line 909, in _normalizeargs + for v in sequence: +TypeError: '_ProtocolMeta' object is not iterable ERROR: test-check-interfaces.py output changed Additionally, as will be seen in the next commit, the fact that this code is imported at all has an influence on pytype checking, even when it shouldn't be getting used. Any replacement test will likely be a python file that instantiates things and tries to assign them to variables annotated with a Protocol, and is then checked with pytype. But in the meantime, the explicit subclassing of the Protocol classes will give us some coverage.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 07 Dec 2024 03:07:04 -0500
parents 24c3b3dbab08
children cdb45eb77efb
files contrib/import-checker.py contrib/python3-whitelist tests/test-check-interfaces.py tests/test-check-interfaces.py.out tests/test-check-module-imports.t
diffstat 4 files changed, 0 insertions(+), 273 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/import-checker.py	Wed Dec 04 15:05:56 2024 +0100
+++ b/contrib/import-checker.py	Sat Dec 07 03:07:04 2024 -0500
@@ -43,8 +43,6 @@
     'mercurial.thirdparty.attr',
     'mercurial.thirdparty.jaraco.collections',
     'mercurial.thirdparty.tomli',
-    'mercurial.thirdparty.zope',
-    'mercurial.thirdparty.zope.interface',
     'typing',
     'xml.etree.ElementTree',
 )
--- a/contrib/python3-whitelist	Wed Dec 04 15:05:56 2024 +0100
+++ b/contrib/python3-whitelist	Sat Dec 07 03:07:04 2024 -0500
@@ -72,7 +72,6 @@
 test-check-config.t
 test-check-execute.t
 test-check-help.t
-test-check-interfaces.py
 test-check-module-imports.t
 test-check-pyflakes.t
 test-check-pylint.t
--- a/tests/test-check-interfaces.py	Wed Dec 04 15:05:56 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,269 +0,0 @@
-# Test that certain objects conform to well-defined interfaces.
-
-
-from mercurial import encoding
-
-encoding.environ[b'HGREALINTERFACES'] = b'1'
-
-import os
-import subprocess
-import sys
-
-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 import (
-    bundlerepo,
-    dirstate,
-    filelog,
-    httppeer,
-    localrepo,
-    manifest,
-    pycompat,
-    revlog,
-    sshpeer,
-    statichttprepo,
-    ui as uimod,
-    unionrepo,
-    vfs as vfsmod,
-    wireprotoserver,
-    wireprototypes,
-    wireprotov1peer,
-)
-
-testdir = os.path.dirname(__file__)
-
-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)
-    if not ifaces:
-        print('%r does not provide any zope interfaces' % o)
-        return
-
-    # Run zope.interface's built-in verification routine. This verifies that
-    # everything that is supposed to be present is present.
-    for iface in ifaces:
-        ziverify.verifyObject(iface, o)
-
-    if allowextra:
-        return
-
-    # Now verify that the object provides no extra public attributes that
-    # aren't declared as part of interfaces.
-    allowed = set()
-    for iface in ifaces:
-        allowed |= set(iface.names(all=True))
-
-    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)
-        )
-
-
-# Facilitates testing localpeer.
-class dummyrepo:
-    def __init__(self):
-        self.ui = uimod.ui()
-        self._wanted_sidedata = set()
-
-    def filtered(self, name):
-        pass
-
-    def _restrictcapabilities(self, caps):
-        pass
-
-
-class dummyopener:
-    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
-        )
-        self.badattribute = True
-
-    def badmethod(self):
-        pass
-
-
-class dummypipe:
-    def close(self):
-        pass
-
-    @property
-    def closed(self):
-        pass
-
-
-def init_test_repo():
-    testtmp_dir = os.path.normpath(os.environ['TESTTMP'])
-    test_repo_dir = os.path.join(testtmp_dir, "test-repo")
-    subprocess.run(["hg", "init", test_repo_dir])
-    subprocess.run(["hg", "--cwd", test_repo_dir, "debugbuilddag", "+3<3+1"])
-    return test_repo_dir
-
-
-def main():
-    ui = uimod.ui()
-    # Needed so we can open a local repo with obsstore without a warning.
-    ui.setconfig(b'experimental', b'evolution.createmarkers', True)
-
-    checkzobject(badpeer())
-
-    ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer)
-    checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
-
-    ziverify.verifyClass(repository.ipeerbase, localrepo.localpeer)
-    checkzobject(localrepo.localpeer(dummyrepo()))
-
-    ziverify.verifyClass(
-        repository.ipeercommandexecutor, localrepo.localcommandexecutor
-    )
-    checkzobject(localrepo.localcommandexecutor(None))
-
-    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,
-        )
-    )
-
-    ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
-    checkzobject(bundlerepo.bundlepeer(dummyrepo()))
-
-    ziverify.verifyClass(repository.ipeerbase, statichttprepo.statichttppeer)
-    checkzobject(statichttprepo.statichttppeer(dummyrepo()))
-
-    ziverify.verifyClass(repository.ipeerbase, unionrepo.unionpeer)
-    checkzobject(unionrepo.unionpeer(dummyrepo()))
-
-    ziverify.verifyClass(
-        repository.ilocalrepositorymain, localrepo.localrepository
-    )
-    ziverify.verifyClass(
-        repository.ilocalrepositoryfilestorage, localrepo.revlogfilestorage
-    )
-    test_repo_dir = init_test_repo()
-    repo = localrepo.makelocalrepository(ui, pycompat.fsencode(test_repo_dir))
-    checkzobject(repo)
-
-    ziverify.verifyClass(
-        wireprototypes.baseprotocolhandler, wireprotoserver.sshv1protocolhandler
-    )
-    ziverify.verifyClass(
-        wireprototypes.baseprotocolhandler,
-        wireprotoserver.httpv1protocolhandler,
-    )
-
-    sshv1 = wireprotoserver.sshv1protocolhandler(None, None, None)
-    checkzobject(sshv1)
-
-    httpv1 = wireprotoserver.httpv1protocolhandler(None, None, None)
-    checkzobject(httpv1)
-
-    ziverify.verifyClass(repository.ifilestorage, filelog.filelog)
-    ziverify.verifyClass(repository.imanifestdict, manifest.manifestdict)
-    ziverify.verifyClass(repository.imanifestdict, manifest.treemanifest)
-    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.ifilestorage, simplestorerepo.filestorage)
-    ziverify.verifyClass(
-        repository.iverifyproblem, simplestorerepo.simplefilestoreproblem
-    )
-
-    ziverify.verifyClass(intdirstate.idirstate, dirstate.dirstate)
-
-    vfs = vfsmod.vfs(b'.')
-    fl = filelog.filelog(vfs, b'dummy.i')
-    checkzobject(fl, allowextra=True)
-
-    # Conforms to imanifestlog.
-    ml = manifest.manifestlog(
-        vfs,
-        repo,
-        manifest.manifestrevlog(repo.nodeconstants, repo.svfs),
-        repo.narrowmatch(),
-    )
-    checkzobject(ml)
-    checkzobject(repo.manifestlog)
-
-    # Conforms to imanifestrevision.
-    mctx = ml[repo[0].manifestnode()]
-    checkzobject(mctx)
-
-    # Conforms to imanifestrevisionwritable.
-    checkzobject(mctx.copy())
-
-    # Conforms to imanifestdict.
-    checkzobject(mctx.read())
-
-    mrl = manifest.manifestrevlog(repo.nodeconstants, vfs)
-    checkzobject(mrl)
-
-    ziverify.verifyClass(repository.irevisiondelta, revlog.revlogrevisiondelta)
-
-    rd = revlog.revlogrevisiondelta(
-        node=b'',
-        p1node=b'',
-        p2node=b'',
-        basenode=b'',
-        linknode=b'',
-        flags=b'',
-        baserevisionsize=None,
-        revision=b'',
-        sidedata=b'',
-        delta=None,
-        protocol_flags=b'',
-    )
-    checkzobject(rd)
-
-    ziverify.verifyClass(repository.iverifyproblem, revlog.revlogproblem)
-    checkzobject(revlog.revlogproblem())
-
-
-# Skip checking until the interfaces are converted to protocols
-sys.exit(0)
-
-# main()
--- a/tests/test-check-module-imports.t	Wed Dec 04 15:05:56 2024 +0100
+++ b/tests/test-check-module-imports.t	Sat Dec 07 03:07:04 2024 -0500
@@ -37,7 +37,6 @@
   > -X i18n/posplit \
   > -X mercurial/thirdparty \
   > -X tests/hypothesishelpers.py \
-  > -X tests/test-check-interfaces.py \
   > -X tests/test-demandimport.py \
   > -X tests/test-imports-checker.t \
   > -X tests/test-verify-repo-operations.py \