Exemplo n.º 1
0
 def test_guess_encoding_and_decode(self):
     for header in DECODED_HEADERS:
         try:
             encoding.guess_encoding_and_decode('ascii',
                                                header.encode('utf-8'))
         except encoding.EncodingError:
             pass
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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')
Exemplo n.º 4
0
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
Exemplo n.º 5
0
 def test_guess_encoding_and_decode_unicode_error(self, detect_mock):
     data = "testß".encode("latin-1")
     detect_mock.return_value = {"confidence": 0.99, "encoding": "utf-8"}
     with self.assertRaises(encoding.EncodingError):
         encoding.guess_encoding_and_decode("ascii", data)
Exemplo n.º 6
0
 def test_guess_encoding_fails_completely(self):
     chardet.detect.return_value = {'encoding': None, 'confidence': 0.0}
     with self.assertRaises(encoding.EncodingError):
         encoding.guess_encoding_and_decode('ascii',
                                            'some data',
                                            errors='strict')
Exemplo n.º 7
0
def test_guess_encoding_and_decode_unicode_error(detect_mock):
    data = u"testß".encode("latin-1")
    detect_mock.return_value = {"confidence": 0.99, "encoding": "utf-8"}
    encoding.guess_encoding_and_decode("ascii", data)
Exemplo n.º 8
0
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')
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
def test_guess_encoding_and_decode_unicode_error(detect_mock):
    data = u"testß".encode("latin-1")
    detect_mock.return_value = {"confidence": 0.99, "encoding": "utf-8"}
    encoding.guess_encoding_and_decode("ascii", data)
Exemplo n.º 11
0
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")