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')
Exemple #2
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')
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,
        )
Exemple #4
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)
Exemple #5
0
def test_decode_text_ascii():
    value = 'abc'
    assert decode_text(value.encode('ascii')) == value
Exemple #6
0
def test_decode_text_unicode():
    value = u'\uffff'
    decoded = decode_text(value)
    assert decoded == value
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