def test_guess_encoding_and_decode_unicode_error(): data = Mock() data.__str__ = Mock() data.__str__.return_value = u"\0\0" data.decode.side_effect = raises_UnicodeError encoding.guess_encoding_and_decode("ascii", data)
def test_guess_encoding_fails_completely(): chardet.detect.return_value = {'encoding': None, 'confidence': 0.0} encoding.guess_encoding_and_decode('ascii', 'some data', errors='strict')
def test_guess_encoding_and_decode(): for header in DECODED_HEADERS: try: encoding.guess_encoding_and_decode('ascii', header.encode('utf-8')) except encoding.EncodingError: pass