def test_decode_text_non_ascii(): value = b'abc \xff xyz' assert isinstance(value, bytes) decoded = decode_text(value) assert not isinstance(decoded, bytes) assert decoded.startswith('abc') assert decoded.endswith('xyz')
def _printable(value): try: return decode_text(repr(value)) except Exception as e: return "<repr(%s) raised %s: %s>" % ( object.__repr__(value), type(e).__name__, e, )
def _printable(value): try: return decode_text(repr(value)) except Exception as e: return '<repr(%s) raised %s: %s>' % ( object.__repr__(value), type(e).__name__, e)
def test_decode_text_ascii(): value = 'abc' assert decode_text(value.encode('ascii')) == value
def test_decode_text_unicode(): value = u'\uffff' decoded = decode_text(value) assert decoded == value