Esempio n. 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'
Esempio n. 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
Esempio n. 3
0
def test_file_with_utf8_editor_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'latin-1'
    assert encoding.lineno == 2
Esempio n. 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
Esempio n. 5
0
def test_file_with_utf16_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'utf-16'
    assert encoding.lineno == 1
Esempio n. 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'
Esempio n. 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'
Esempio n. 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'