def test_getRootObject(self):
        """
        Assert that L{PBClientFactory.getRootObject}'s Deferred fires with
        a L{RemoteReference}, and that disconnecting it runs its
        disconnection callbacks.
        """
        self.establishClientAndServer()
        rootObjDeferred = self.clientFactory.getRootObject()

        def gotRootObject(rootObj):
            self.assertIsInstance(rootObj, pb.RemoteReference)
            return rootObj

        def disconnect(rootObj):
            disconnectedDeferred = Deferred()
            rootObj.notifyOnDisconnect(disconnectedDeferred.callback)
            self.clientFactory.disconnect()

            self.completeClientLostConnection()

            return disconnectedDeferred

        rootObjDeferred.addCallback(gotRootObject)
        rootObjDeferred.addCallback(disconnect)

        return rootObjDeferred

        Assert that L{PBClientFactory.getRootObject}'s Deferred fires with
        a L{RemoteReference}, and that disconnecting it runs its
        disconnection callbacks.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/spread/test/test_pb.py