'An exception raised in C{buildProtocol} of our wrappedFactory
results in our C{onConnection} errback being fired.'

def test_failedBuildProtocol(self):

    class BogusFactory(ClientFactory, ):
        '\n                                                A    one    off    factory    whose    C{buildProtocol}    raises    an    C{Exception}.\n                                                '
        def buildProtocol(self, addr):
            raise ValueError('My    protocol    is    poorly    defined.')
    wf = endpoints._WrappingFactory(BogusFactory())
    wf.buildProtocol(None)
    d = self.assertFailure(wf._onConnection, ValueError)
    d.addCallback((lambda e: self.assertEqual(e.args, ('My    protocol    is    poorly    defined.',))))
    return d
