[Twisted-Python] how to unitest this?

sonium sonium at gmail.com
Fri Nov 4 11:17:08 EST 2005


hi, I just read the introduction about unittesting on diveintopython and 
now asked myself how I could write a unittest for the connectionmade 
function in the code below taken from the tutorial:

from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor

class QOTD(Protocol):

    def connectionMade(self):
        self.transport.write("An apple a day keeps the doctor away\r\n")
        self.transport.loseConnection()


# Next lines are magic:
factory = Factory()
factory.protocol = QOTD

# 8007 is the port you want to run under.
reactor.listenTCP(8007, factory)
reactor.run()


I know there is twisted.trail, but I haven't found any useful 
information about it yet.
Or is mockobjects the thing I am looking for?




More information about the Twisted-Python mailing list