def errorCheck(self, err, proto, cmd, **kw):
        """
        Check that the appropriate kind of error is raised when a given command
        is sent to a given protocol.
        """
        c, s, p = connectedServerAndClient(ServerClass=proto,
                                           ClientClass=proto)
        d = c.callRemote(cmd, **kw)
        d2 = self.failUnlessFailure(d, err)
        p.flush()
        return d2

        Check that the appropriate kind of error is raised when a given command
        is sent to a given protocol.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_amp.py