'Drain the bytes currently pending write from a L{StringTransport}, then
clear it, since those bytes have been consumed.
@param transport: The L{StringTransport} to get the bytes from.
@type transport: L{StringTransport}
@param allowEmpty: Allow the test to pass even if the transport has no
outgoing bytes in it.
@type allowEmpty: L{bool}
@return: the outgoing bytes from the given transport
@rtype: L{bytes}'

def drain(self, transport, allowEmpty=False):

    value = transport.value()
    transport.clear()
    self.assertEqual(bool((allowEmpty or value)), True)
    return value
