コード例 #1
0
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')
コード例 #2
0
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)
コード例 #3
0
def test_decode_text_ascii():
    value = 'abc'
    assert decode_text(value.encode('ascii')) == value
コード例 #4
0
def test_decode_text_unicode():
    value = u'\uffff'
    decoded = decode_text(value)
    assert decoded == value