[Twisted-Python] Unit tests, inline callbacks, and exception handling

Terry Jones terry at jon.es
Thu Sep 24 13:08:39 EDT 2009


Hi Patrick

You have

    try:
        client2 = Client(username = "Test")
        yield client2.connect(port = server_port)
        assert False
    except UsernameAlreadyExists, ex:
        pass

You could instead try:

    client2 = Client(username = "Test")
    d = client2.connect(port = server_port)
    self.failUnlessFailure(d, UsernameAlreadyExists)
    yield d

Terry



More information about the Twisted-Python mailing list