Fix issues with PDF.js path changes
This commit is contained in:
parent
28ca292b9e
commit
b5b4fda676
@ -54,10 +54,11 @@ def generate_pdfjs_page(filename, url):
|
|||||||
url: The URL being opened.
|
url: The URL being opened.
|
||||||
"""
|
"""
|
||||||
if not is_available():
|
if not is_available():
|
||||||
|
pdfjs_dir = os.path.join(standarddir.data(), 'pdfjs')
|
||||||
return jinja.render('no_pdfjs.html',
|
return jinja.render('no_pdfjs.html',
|
||||||
url=url.toDisplayString(),
|
url=url.toDisplayString(),
|
||||||
title="PDF.js not found",
|
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')
|
html = get_pdfjs_res('web/viewer.html').decode('utf-8')
|
||||||
|
|
||||||
script = _generate_pdfjs_script(filename)
|
script = _generate_pdfjs_script(filename)
|
||||||
|
@ -166,7 +166,7 @@ def clean_open_tabs(quteproc):
|
|||||||
|
|
||||||
|
|
||||||
@bdd.given('pdfjs is available')
|
@bdd.given('pdfjs is available')
|
||||||
def pdfjs_available():
|
def pdfjs_available(data_tmpdir):
|
||||||
if not pdfjs.is_available():
|
if not pdfjs.is_available():
|
||||||
pytest.skip("No pdfjs installation found.")
|
pytest.skip("No pdfjs installation found.")
|
||||||
|
|
||||||
|
@ -26,10 +26,7 @@ from qutebrowser.browser import pdfjs
|
|||||||
from qutebrowser.utils import usertypes, utils
|
from qutebrowser.utils import usertypes, utils
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
pytestmark = [pytest.mark.usefixtures('data_tmpdir')]
|
||||||
def patch_data_dir(monkeypatch, tmpdir):
|
|
||||||
monkeypatch.setattr(pdfjs.standarddir, 'data',
|
|
||||||
lambda: str(tmpdir / 'data'))
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('available, snippet', [
|
@pytest.mark.parametrize('available, snippet', [
|
||||||
|
@ -207,7 +207,7 @@ class TestPDFJSHandler:
|
|||||||
assert (caplog.records[0].message ==
|
assert (caplog.records[0].message ==
|
||||||
'pdfjs resource requested but not found: /no/file.html')
|
'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."""
|
"""Load the /web/viewer.html page."""
|
||||||
_mimetype, data = qutescheme.data_for_url(
|
_mimetype, data = qutescheme.data_for_url(
|
||||||
QUrl('qute://pdfjs/web/viewer.html?filename=foobar'))
|
QUrl('qute://pdfjs/web/viewer.html?filename=foobar'))
|
||||||
|
Loading…
Reference in New Issue
Block a user