summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/end2end/features/test_history_bdd.py1
-rw-r--r--tests/end2end/fixtures/quteprocess.py1
-rw-r--r--tests/unit/components/test_braveadblock.py13
-rw-r--r--tests/unit/components/test_hostblock.py10
-rw-r--r--tests/unit/config/test_configutils.py23
-rw-r--r--tests/unit/scripts/test_check_coverage.py5
-rw-r--r--tests/unit/utils/test_urlutils.py23
7 files changed, 52 insertions, 24 deletions
diff --git a/tests/end2end/features/test_history_bdd.py b/tests/end2end/features/test_history_bdd.py
index 29958c3e6..f2e018b9f 100644
--- a/tests/end2end/features/test_history_bdd.py
+++ b/tests/end2end/features/test_history_bdd.py
@@ -33,6 +33,7 @@ def turn_on_sql_history(quteproc):
cmd = ":debug-pyeval objects.debug_flags.remove('no-sql-history')"
quteproc.send_cmd(cmd)
quteproc.wait_for_load_finished_url('qute://pyeval')
+ quteproc.wait_for(message='INSERT INTO History *', category='sql')
@bdd.then(bdd.parsers.parse("the query parameter {name} should be set to "
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 264c81283..8555834e9 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -334,6 +334,7 @@ def is_ignored_chromium_message(line):
'filtering (maybe)?'),
('[.DisplayCompositor]GL ERROR :GL_INVALID_OPERATION : '
'DoEndSharedImageAccessCHROMIUM: bound texture is not a shared image'),
+ 'Unable to map Index file',
# WebRTC with Qt 5.13 / 5.14
'Failed to query stereo recording.',
diff --git a/tests/unit/components/test_braveadblock.py b/tests/unit/components/test_braveadblock.py
index 02f7c1074..fc50cb595 100644
--- a/tests/unit/components/test_braveadblock.py
+++ b/tests/unit/components/test_braveadblock.py
@@ -29,6 +29,7 @@ import pytest
from qutebrowser.api.interceptor import ResourceType
from qutebrowser.components import braveadblock
from qutebrowser.components.utils import blockutils
+from qutebrowser.utils import usertypes
from helpers import testutils
pytestmark = pytest.mark.usefixtures("qapp")
@@ -417,3 +418,15 @@ def test_buggy_url_workaround_needed(ad_blocker, config_stub, easylist_easypriva
request_type=resource_type_str
)
assert result.matched
+
+
+def test_corrupt_cache_handling(ad_blocker, message_mock, caplog):
+ ad_blocker._cache_path.write_text("blablub")
+
+ with caplog.at_level(logging.ERROR):
+ ad_blocker.read_cache()
+
+ msg = message_mock.getmsg(usertypes.MessageLevel.error)
+ assert msg.text == (
+ "Reading adblock filter data failed (corrupted data?). "
+ "Please run :adblock-update.")
diff --git a/tests/unit/components/test_hostblock.py b/tests/unit/components/test_hostblock.py
index 8dd8d6dda..00a7a5f8f 100644
--- a/tests/unit/components/test_hostblock.py
+++ b/tests/unit/components/test_hostblock.py
@@ -279,7 +279,7 @@ def test_disabled_blocking_per_url(config_stub, host_blocker_factory):
pattern = urlmatch.UrlPattern(example_com)
config_stub.set_obj("content.blocking.enabled", False, pattern=pattern)
- url = QUrl("blocked.example.com")
+ url = QUrl("https://blocked.example.com")
host_blocker = host_blocker_factory()
host_blocker._blocked_hosts.add(url.host())
@@ -563,3 +563,11 @@ def test_adblock_benchmark(data_tmpdir, benchmark, host_blocker_factory):
assert blocker._blocked_hosts
benchmark(lambda: blocker._is_blocked(url))
+
+
+def test_subdomain_blocking(config_stub, host_blocker_factory):
+ config_stub.val.content.blocking.method = "hosts"
+ config_stub.val.content.blocking.hosts.lists = None
+ host_blocker = host_blocker_factory()
+ host_blocker._blocked_hosts.add("example.com")
+ assert host_blocker._is_blocked(QUrl("https://subdomain.example.com"))
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py
index e06463bb4..e7ce15aff 100644
--- a/tests/unit/config/test_configutils.py
+++ b/tests/unit/config/test_configutils.py
@@ -300,29 +300,6 @@ def test_domain_lookup_sparse_benchmark(url, values, benchmark):
benchmark(lambda: values.get_for_url(url))
-class TestWiden:
-
- @pytest.mark.parametrize('hostname, expected', [
- ('a.b.c', ['a.b.c', 'b.c', 'c']),
- ('foobarbaz', ['foobarbaz']),
- ('', []),
- ('.c', ['.c', 'c']),
- ('c.', ['c.']),
- ('.c.', ['.c.', 'c.']),
- (None, []),
- ])
- def test_widen_hostnames(self, hostname, expected):
- assert list(configutils._widened_hostnames(hostname)) == expected
-
- @pytest.mark.parametrize('hostname', [
- 'test.qutebrowser.org',
- 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.z.y.z',
- 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq.c',
- ])
- def test_bench_widen_hostnames(self, hostname, benchmark):
- benchmark(lambda: list(configutils._widened_hostnames(hostname)))
-
-
class TestFontFamilies:
@pytest.mark.parametrize('family_str, expected', [
diff --git a/tests/unit/scripts/test_check_coverage.py b/tests/unit/scripts/test_check_coverage.py
index efd35ce82..abb0969b6 100644
--- a/tests/unit/scripts/test_check_coverage.py
+++ b/tests/unit/scripts/test_check_coverage.py
@@ -98,7 +98,12 @@ def covtest(testdir, monkeypatch):
# Check if coverage plugin is available
res = testdir.runpytest('--version', '--version')
assert res.ret == 0
+
output = res.stderr.str()
+ if not output:
+ # pytest >= 7.0: https://github.com/pytest-dev/pytest/pull/8247
+ output = res.stdout.str()
+
assert 'This is pytest version' in output
if 'pytest-cov' not in output:
pytest.skip("cov plugin not available")
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index a5599c6c9..97ff268ca 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -778,3 +778,26 @@ class TestParseJavascriptUrl:
pass
else:
assert parsed == source
+
+
+class TestWiden:
+
+ @pytest.mark.parametrize('hostname, expected', [
+ ('a.b.c', ['a.b.c', 'b.c', 'c']),
+ ('foobarbaz', ['foobarbaz']),
+ ('', []),
+ ('.c', ['.c', 'c']),
+ ('c.', ['c.']),
+ ('.c.', ['.c.', 'c.']),
+ (None, []),
+ ])
+ def test_widen_hostnames(self, hostname, expected):
+ assert list(urlutils.widened_hostnames(hostname)) == expected
+
+ @pytest.mark.parametrize('hostname', [
+ 'test.qutebrowser.org',
+ 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.z.y.z',
+ 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq.c',
+ ])
+ def test_bench_widen_hostnames(self, hostname, benchmark):
+ benchmark(lambda: list(urlutils.widened_hostnames(hostname)))