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'
def test_file_with_utf8_plain_text_coding(file): encoding = _find_file_encoding(file) assert encoding.name == 'utf-8' assert encoding.lineno == 1
def test_file_with_utf8_editor_coding(file): encoding = _find_file_encoding(file) assert encoding.name == 'latin-1' assert encoding.lineno == 2
def test_file_with_utf8_coding_in_second_line(file): encoding = _find_file_encoding(file) assert encoding.name == 'utf-8' assert encoding.lineno == 2
def test_file_with_utf16_coding(file): encoding = _find_file_encoding(file) assert encoding.name == 'utf-16' assert encoding.lineno == 1
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'
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'
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'