'Test the C{__str__} and C{__repr__} implementations of a UNIX datagram
port when used with the given protocol.'

def _reprTest(self, serverProto, protocolName):

    filename = self.mktemp()
    unixPort = reactor.listenUNIXDatagram(filename, serverProto)
    connectedString = ('<%s    on    %r>' % (protocolName, filename))
    self.assertEqual(repr(unixPort), connectedString)
    self.assertEqual(str(unixPort), connectedString)
    stopDeferred = defer.maybeDeferred(unixPort.stopListening)
    def stoppedListening(ign):
        unconnectedString = ('<%s    (not    listening)>' % (protocolName,))
        self.assertEqual(repr(unixPort), unconnectedString)
        self.assertEqual(str(unixPort), unconnectedString)
    stopDeferred.addCallback(stoppedListening)
    return stopDeferred
