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

def _reprTest(self, serverFactory, factoryName):

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