示例#1
0
def test_file_with_missing_coding_prefix(file):
    with pytest.raises(LookupError) as excinfo:
        _find_file_encoding(file)
    assert str(excinfo.value) == 'encoding not found'
示例#2
0
def test_file_with_utf8_plain_text_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'utf-8'
    assert encoding.lineno == 1
示例#3
0
def test_file_with_utf8_editor_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'latin-1'
    assert encoding.lineno == 2
示例#4
0
def test_file_with_utf8_coding_in_second_line(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'utf-8'
    assert encoding.lineno == 2
示例#5
0
def test_file_with_utf16_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'utf-16'
    assert encoding.lineno == 1
示例#6
0
def test_file_without_content_2(empty_file):
    with pytest.raises(LookupError) as excinfo:
        _find_file_encoding(empty_file)
    assert str(excinfo.value) == 'encoding not found'
示例#7
0
def test_file_with_invalid_coding(file):
    with pytest.raises(ValueError) as excinfo:
        _find_file_encoding(file)
    assert str(excinfo.value) == 'unknown encoding: utf-42'
示例#8
0
def test_file_with_utf8_coding_in_third_line(file):
    with pytest.raises(LookupError) as excinfo:
        _find_file_encoding(file)
    assert str(excinfo.value) == 'encoding not found'