コード例 #1
0
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
def test_file_with_utf8_editor_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'latin-1'
    assert encoding.lineno == 2
コード例 #4
0
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
def test_file_with_utf16_coding(file):
    encoding = _find_file_encoding(file)
    assert encoding.name == 'utf-16'
    assert encoding.lineno == 1
コード例 #6
0
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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
ファイル: test_find_encoding.py プロジェクト: B3QL/pep263
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'