'A buffer is always bytes, but sometimes
we need to compare it to a utf-8 unicode string
@param buf: the buffer
@type buf: L{bytes} or L{unicode} or L{list}
@param val: the value to compare
@type val: L{bytes} or L{unicode} or L{list}'

def assertEqualBufferValue(self, buf, val):

    bufferValue = buf
    if isinstance(val, unicode):
        bufferValue = bufferValue.decode('utf-8')
    if isinstance(bufferValue, list):
        if isinstance(val[0], unicode):
            bufferValue = [b.decode('utf8') for b in bufferValue]
    self.assertEqual(bufferValue, val)
