示例#1
0
def test_read_from_system_oserror(tmpdir, caplog, unreadable_file):
    expected = (None, None)
    with caplog.at_level(logging.WARNING):
        assert pdfjs._read_from_system(str(tmpdir), ['unreadable']) == expected

    assert len(caplog.records) == 1
    message = caplog.messages[0]
    assert message.startswith('OSError while reading PDF.js file:')
示例#2
0
def test_read_from_system(names, expected_name, tmpdir):
    file1 = tmpdir / 'one'
    file1.write_text('text1', encoding='ascii')
    file2 = tmpdir / 'two'
    file2.write_text('text2', encoding='ascii')

    if expected_name == 'one':
        expected = (b'text1', str(file1))
    elif expected_name == 'two':
        expected = (b'text2', str(file2))
    elif expected_name is None:
        expected = (None, None)

    assert pdfjs._read_from_system(str(tmpdir), names) == expected
示例#3
0
def test_read_from_system(names, expected_name, tmpdir):
    file1 = tmpdir / 'one'
    file1.write_text('text1', encoding='ascii')
    file2 = tmpdir / 'two'
    file2.write_text('text2', encoding='ascii')

    if expected_name == 'one':
        expected = (b'text1', str(file1))
    elif expected_name == 'two':
        expected = (b'text2', str(file2))
    elif expected_name is None:
        expected = (None, None)

    assert pdfjs._read_from_system(str(tmpdir), names) == expected
示例#4
0
def test_read_from_system_oserror(tmpdir, caplog):
    unreadable_file = tmpdir / 'unreadable'
    unreadable_file.ensure()
    unreadable_file.chmod(0)
    if os.access(str(unreadable_file), os.R_OK):
        # Docker container or similar
        pytest.skip("File was still readable")

    expected = (None, None)
    with caplog.at_level(logging.WARNING):
        assert pdfjs._read_from_system(str(tmpdir), ['unreadable']) == expected

    assert len(caplog.records) == 1
    message = caplog.messages[0]
    assert message.startswith('OSError while reading PDF.js file:')
示例#5
0
def test_read_from_system_oserror(tmpdir, caplog):
    unreadable_file = tmpdir / 'unreadable'
    unreadable_file.ensure()
    unreadable_file.chmod(0)
    if os.access(str(unreadable_file), os.R_OK):
        # Docker container or similar
        pytest.skip("File was still readable")

    expected = (None, None)
    with caplog.at_level(logging.WARNING):
        assert pdfjs._read_from_system(str(tmpdir), ['unreadable']) == expected

    assert len(caplog.records) == 1
    rec = caplog.records[0]
    assert rec.message.startswith('OSError while reading PDF.js file:')