예제 #1
0
def test_cached_encodings():
    s = Cache(suffix='-pytest')
    s.clear()
    # not in cache
    with pytest.raises(KeyError):
        s.get_file_encoding(__file__)
    s.set_file_encoding(__file__, 'utf_16')
    s = Cache(suffix='-pytest')
    assert s.get_file_encoding(__file__) == 'utf_16'
예제 #2
0
def test_cached_encodings():
    s = Cache(suffix='-pytest')
    s.clear()
    # not in cache
    with pytest.raises(KeyError):
        s.get_file_encoding(
            os.path.join(os.getcwd(), 'test', 'files', 'big5hkscs.txt'))
    s.set_file_encoding(__file__, 'utf_16')
    s = Cache(suffix='-pytest')
    assert s.get_file_encoding(__file__) == 'utf_16'
예제 #3
0
def test_preferred_encodings():
    cache = Cache(suffix='-pytest')
    cache.clear()
    encodings = cache.preferred_encodings
    assert len(encodings) == 1
    assert encodings[0] == convert_to_codec_key(locale.getpreferredencoding())
    encodings.append('utf_16')
    cache.preferred_encodings = encodings
    cache2 = Cache(suffix='-pytest')
    assert 'utf_16' in cache2.preferred_encodings
예제 #4
0
def test_cached_encodings():
    s = Cache(suffix='-pytest')
    s.clear()
    # not in cache
    with pytest.raises(KeyError):
        s.get_file_encoding(os.path.join(os.getcwd(), 'test', 'files',
                                         'big5hkscs.txt'))
    s.set_file_encoding(__file__, 'utf_16')
    s = Cache(suffix='-pytest')
    assert s.get_file_encoding(__file__) == 'utf_16'
예제 #5
0
def test_preferred_encodings():
    cache = Cache(suffix='-pytest')
    cache.clear()
    encodings = cache.preferred_encodings
    assert len(encodings) == 1
    assert encodings[0] == convert_to_codec_key(
        locale.getpreferredencoding())
    encodings.append('utf_16')
    cache.preferred_encodings = encodings
    cache2 = Cache(suffix='-pytest')
    assert 'utf_16' in cache2.preferred_encodings