'Disconnect the dummy XMPP client.
Can be safely called even if stream_start has not been called.
Must be placed in the tearDown method of a test class to ensure
that the XMPP client is disconnected after an error.'

def stream_close(self):

    if (hasattr(self, 'xmpp') and (self.xmpp is not None)):
        self.xmpp.socket.recv_data(self.xmpp.stream_footer)
        self.xmpp.disconnect()
