'Since any client of L{IStreamClientEndpoint} needs to handle Deferred
failures from C{connect}, L{HostnameEndpoint}\'s constructor will not
raise exceptions when given bad host names, instead deferring to
returning a failing L{Deferred} from C{connect}.'

def test_deferBadEncodingToConnect(self):

    endpoint = endpoints.HostnameEndpoint(deterministicResolvingReactor(MemoryReactor(), ['127.0.0.1']), '\xff-garbage-\xff', 80)
    deferred = endpoint.connect(Factory.forProtocol(Protocol))
    err = self.failureResultOf(deferred, ValueError)
    self.assertIn('\\xff-garbage-\\xff', str(err))
    endpoint = endpoints.HostnameEndpoint(deterministicResolvingReactor(MemoryReactor(), ['127.0.0.1']), u'\u2ff0-garbage-\u2ff0', 80)
    deferred = endpoint.connect(Factory())
    err = self.failureResultOf(deferred, ValueError)
    self.assertIn('\\u2ff0-garbage-\\u2ff0', str(err))
