From bb96f8d297aa04a58c92befdefc3d5d39e98d858 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 10 Sep 2018 09:36:29 +0200 Subject: [PATCH] Fix PDF.js test when no PDF.js is installed --- tests/unit/browser/test_pdfjs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py index be2070292..43bb2c38e 100644 --- a/tests/unit/browser/test_pdfjs.py +++ b/tests/unit/browser/test_pdfjs.py @@ -25,11 +25,20 @@ from qutebrowser.utils import usertypes @pytest.mark.parametrize('available, snippet', [ - (True, 'PDF.js viewer'), + pytest.param(True, 'PDF.js viewer', + marks=pytest.mark.skipif(not pdfjs.is_available(), + reason='PDF.js unavailable')), (False, '

No pdf.js installation found

'), + ('force', 'fake PDF.js'), ]) def test_generate_pdfjs_page(available, snippet, monkeypatch): - monkeypatch.setattr(pdfjs, 'is_available', lambda: available) + if available == 'force': + monkeypatch.setattr(pdfjs, 'is_available', lambda: True) + monkeypatch.setattr(pdfjs, 'get_pdfjs_res', + lambda filename: b'fake PDF.js') + else: + monkeypatch.setattr(pdfjs, 'is_available', lambda: available) + content = pdfjs.generate_pdfjs_page('example.pdf', QUrl()) print(content) assert snippet in content