Fix issues with PDF.js path changes

This commit is contained in:
Florian Bruhin 2018-10-05 14:05:54 +02:00
parent 28ca292b9e
commit b5b4fda676
4 changed files with 5 additions and 7 deletions

View File

@ -54,10 +54,11 @@ def generate_pdfjs_page(filename, url):
url: The URL being opened.
"""
if not is_available():
pdfjs_dir = os.path.join(standarddir.data(), 'pdfjs')
return jinja.render('no_pdfjs.html',
url=url.toDisplayString(),
title="PDF.js not found",
pdfjs_dir=os.path.join(standarddir.data(), 'pdfjs'))
pdfjs_dir=pdfjs_dir)
html = get_pdfjs_res('web/viewer.html').decode('utf-8')
script = _generate_pdfjs_script(filename)

View File

@ -166,7 +166,7 @@ def clean_open_tabs(quteproc):
@bdd.given('pdfjs is available')
def pdfjs_available():
def pdfjs_available(data_tmpdir):
if not pdfjs.is_available():
pytest.skip("No pdfjs installation found.")

View File

@ -26,10 +26,7 @@ from qutebrowser.browser import pdfjs
from qutebrowser.utils import usertypes, utils
@pytest.fixture(autouse=True)
def patch_data_dir(monkeypatch, tmpdir):
monkeypatch.setattr(pdfjs.standarddir, 'data',
lambda: str(tmpdir / 'data'))
pytestmark = [pytest.mark.usefixtures('data_tmpdir')]
@pytest.mark.parametrize('available, snippet', [

View File

@ -207,7 +207,7 @@ class TestPDFJSHandler:
assert (caplog.records[0].message ==
'pdfjs resource requested but not found: /no/file.html')
def test_viewer_page(self):
def test_viewer_page(self, data_tmpdir):
"""Load the /web/viewer.html page."""
_mimetype, data = qutescheme.data_for_url(
QUrl('qute://pdfjs/web/viewer.html?filename=foobar'))