コード例 #1
0
ファイル: utils_test.py プロジェクト: yooper/talon
def test_detect_encoding():
    eq_ ('ascii', u.detect_encoding(b'qwe').lower())
    eq_ ('iso-8859-2', u.detect_encoding(u'Versi\xf3n'.encode('iso-8859-2')).lower())
    eq_ ('utf-8', u.detect_encoding(u'привет'.encode('utf8')).lower())
    # fallback to utf-8
    with patch.object(u.chardet, 'detect') as detect:
        detect.side_effect = Exception
        eq_ ('utf-8', u.detect_encoding('qwe'.encode('utf8')).lower())
コード例 #2
0
ファイル: utils_test.py プロジェクト: digideskio/talon
def test_detect_encoding():
    eq_ ('ascii', u.detect_encoding(b'qwe').lower())
    eq_ ('iso-8859-2', u.detect_encoding(u'Versi\xf3n'.encode('iso-8859-2')).lower())
    eq_ ('utf-8', u.detect_encoding(u'привет'.encode('utf8')).lower())
    # fallback to utf-8
    with patch.object(u.chardet, 'detect') as detect:
        detect.side_effect = Exception
        eq_ ('utf-8', u.detect_encoding('qwe'.encode('utf8')).lower())
コード例 #3
0
ファイル: utils_test.py プロジェクト: Projectplace/talon
def test_detect_encoding():
    eq_("ascii", u.detect_encoding(b"qwe").lower())
    ok_(
        u.detect_encoding(u"Versi\xf3n".encode("iso-8859-2")).lower() in
        ["iso-8859-1", "iso-8859-2"])
    eq_("utf-8", u.detect_encoding(u"привет".encode("utf8")).lower())
    # fallback to utf-8
    with patch.object(u.chardet, "detect") as detect:
        detect.side_effect = Exception
        eq_("utf-8", u.detect_encoding("qwe".encode("utf8")).lower())