tests/test-check-interfaces.py
changeset 37914 39c17718f311
parent 37814 265c122b69aa
child 38532 c82ea938efbb
equal deleted inserted replaced
37913:73a74f29eb87 37914:39c17718f311
    23 from mercurial import (
    23 from mercurial import (
    24     bundlerepo,
    24     bundlerepo,
    25     filelog,
    25     filelog,
    26     httppeer,
    26     httppeer,
    27     localrepo,
    27     localrepo,
       
    28     pycompat,
    28     repository,
    29     repository,
    29     sshpeer,
    30     sshpeer,
    30     statichttprepo,
    31     statichttprepo,
    31     ui as uimod,
    32     ui as uimod,
    32     unionrepo,
    33     unionrepo,
    35     wireprototypes,
    36     wireprototypes,
    36     wireprotov1peer,
    37     wireprotov1peer,
    37     wireprotov2server,
    38     wireprotov2server,
    38 )
    39 )
    39 
    40 
    40 rootdir = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
    41 rootdir = pycompat.fsencode(
       
    42     os.path.normpath(os.path.join(os.path.dirname(__file__), '..')))
    41 
    43 
    42 def checkzobject(o, allowextra=False):
    44 def checkzobject(o, allowextra=False):
    43     """Verify an object with a zope interface."""
    45     """Verify an object with a zope interface."""
    44     ifaces = zi.providedBy(o)
    46     ifaces = zi.providedBy(o)
    45     if not ifaces:
    47     if not ifaces:
   104 
   106 
   105     ziverify.verifyClass(repository.ipeerconnection,
   107     ziverify.verifyClass(repository.ipeerconnection,
   106                          httppeer.httpv2peer)
   108                          httppeer.httpv2peer)
   107     ziverify.verifyClass(repository.ipeercapabilities,
   109     ziverify.verifyClass(repository.ipeercapabilities,
   108                          httppeer.httpv2peer)
   110                          httppeer.httpv2peer)
   109     checkzobject(httppeer.httpv2peer(None, '', None, None, None, None))
   111     checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None))
   110 
   112 
   111     ziverify.verifyClass(repository.ipeerbase,
   113     ziverify.verifyClass(repository.ipeerbase,
   112                          localrepo.localpeer)
   114                          localrepo.localpeer)
   113     checkzobject(localrepo.localpeer(dummyrepo()))
   115     checkzobject(localrepo.localpeer(dummyrepo()))
   114 
   116 
   119     ziverify.verifyClass(repository.ipeercommandexecutor,
   121     ziverify.verifyClass(repository.ipeercommandexecutor,
   120                          wireprotov1peer.peerexecutor)
   122                          wireprotov1peer.peerexecutor)
   121     checkzobject(wireprotov1peer.peerexecutor(None))
   123     checkzobject(wireprotov1peer.peerexecutor(None))
   122 
   124 
   123     ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv1peer)
   125     ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv1peer)
   124     checkzobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, dummypipe(),
   126     checkzobject(sshpeer.sshv1peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
   125                                    dummypipe(), None, None))
   127                                    dummypipe(), None, None))
   126 
   128 
   127     ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv2peer)
   129     ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv2peer)
   128     checkzobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, dummypipe(),
   130     checkzobject(sshpeer.sshv2peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
   129                                    dummypipe(), None, None))
   131                                    dummypipe(), None, None))
   130 
   132 
   131     ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
   133     ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
   132     checkzobject(bundlerepo.bundlepeer(dummyrepo()))
   134     checkzobject(bundlerepo.bundlepeer(dummyrepo()))
   133 
   135 
   161     httpv2 = wireprotov2server.httpv2protocolhandler(None, None)
   163     httpv2 = wireprotov2server.httpv2protocolhandler(None, None)
   162     checkzobject(httpv2)
   164     checkzobject(httpv2)
   163 
   165 
   164     ziverify.verifyClass(repository.ifilestorage, filelog.filelog)
   166     ziverify.verifyClass(repository.ifilestorage, filelog.filelog)
   165 
   167 
   166     vfs = vfsmod.vfs('.')
   168     vfs = vfsmod.vfs(b'.')
   167     fl = filelog.filelog(vfs, 'dummy.i')
   169     fl = filelog.filelog(vfs, b'dummy.i')
   168     checkzobject(fl, allowextra=True)
   170     checkzobject(fl, allowextra=True)
   169 
   171 
   170 main()
   172 main()