summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-26 16:49:40 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-26 17:47:38 +0100
commit3abe6b34457aac0102bb2a716cb04709cf377310 (patch)
tree832af335ce52c29bbb55e33c077c4abc82fac41f /tests
parent6d07d2cbf8bc9a5e88002f025ee0c068d9500a66 (diff)
downloadqutebrowser-3abe6b34457aac0102bb2a716cb04709cf377310.tar.gz
qutebrowser-3abe6b34457aac0102bb2a716cb04709cf377310.zip
Serve resource files from qute://resource
See #4467, #5832
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/browser/webkit/network/test_filescheme.py5
-rw-r--r--tests/unit/utils/test_jinja.py24
2 files changed, 3 insertions, 26 deletions
diff --git a/tests/unit/browser/webkit/network/test_filescheme.py b/tests/unit/browser/webkit/network/test_filescheme.py
index 4d97fd847..51ab4472c 100644
--- a/tests/unit/browser/webkit/network/test_filescheme.py
+++ b/tests/unit/browser/webkit/network/test_filescheme.py
@@ -173,9 +173,6 @@ class TestDirbrowserHtml:
def test_icons(self, monkeypatch):
"""Make sure icon paths are correct file:// URLs."""
- monkeypatch.setattr(filescheme.jinja.utils, 'resource_filename',
- lambda name: '/test path/foo.svg')
-
html = filescheme.dirbrowser_html(os.getcwd()).decode('utf-8')
soup = bs4.BeautifulSoup(html, 'html.parser')
@@ -183,7 +180,7 @@ class TestDirbrowserHtml:
print(soup.prettify())
css = soup.html.head.style.string
- assert "background-image: url('file:///test%20path/foo.svg');" in css
+ assert "background-image: url('qute://resource/img/folder.svg');" in css
def test_empty(self, tmpdir, parser):
parsed = parser(str(tmpdir))
diff --git a/tests/unit/utils/test_jinja.py b/tests/unit/utils/test_jinja.py
index 28a7af15a..b62529eb3 100644
--- a/tests/unit/utils/test_jinja.py
+++ b/tests/unit/utils/test_jinja.py
@@ -27,15 +27,13 @@ import jinja2.exceptions
import pytest
from PyQt5.QtCore import QUrl
-from qutebrowser.utils import utils, jinja
+from qutebrowser.utils import jinja
from qutebrowser.config import configexc
@pytest.fixture(autouse=True)
def patch_read_file(monkeypatch):
"""pytest fixture to patch utils.read_file."""
- real_resource_filename = utils.resource_filename
-
def _read_file(path, binary=False):
"""A read_file which returns a simple template if the path is right."""
if path == os.path.join('html', 'test.html'):
@@ -59,16 +57,7 @@ def patch_read_file(monkeypatch):
else:
raise IOError("Invalid path {}!".format(path))
- def _resource_filename(path):
- if path == 'utils/testfile':
- return real_resource_filename(path)
- elif path == 'testfile.txt':
- return path
- else:
- raise IOError("Invalid path {}!".format(path))
-
monkeypatch.setattr(jinja.utils, 'read_file', _read_file)
- monkeypatch.setattr(jinja.utils, 'resource_filename', _resource_filename)
def test_simple_template():
@@ -83,16 +72,7 @@ def test_resource_url():
print(data)
url = QUrl(data)
assert url.isValid()
- assert url.scheme() == 'file'
-
- path = url.path()
-
- if utils.is_windows:
- path = path.lstrip('/')
- path = path.replace('/', os.sep)
-
- with open(path, 'r', encoding='utf-8') as f:
- assert f.read().splitlines()[0] == "Hello World!"
+ assert url.toDisplayString() == 'qute://resource/utils/testfile'
def test_data_url():