diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-01-10 22:11:15 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-01-11 14:25:18 +0100 |
commit | 9a6d027b11c40bb68445f0a68332e35db21cbf92 (patch) | |
tree | b9f07cb7d8611a1e14d104036ad35d7653bca703 /tests/unit/config | |
parent | 2d4eb76b2ee3bc8e3e53fe16ad44e8c78f07b420 (diff) | |
download | qutebrowser-9a6d027b11c40bb68445f0a68332e35db21cbf92.tar.gz qutebrowser-9a6d027b11c40bb68445f0a68332e35db21cbf92.zip |
tests: Compress the blocked-hosts file
This avoids it being matched when searching stuff in the repository.
Diffstat (limited to 'tests/unit/config')
-rw-r--r-- | tests/unit/config/test_configutils.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py index e072c7434..f2fa209b8 100644 --- a/tests/unit/config/test_configutils.py +++ b/tests/unit/config/test_configutils.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. -import os import pytest from PyQt5.QtCore import QUrl @@ -252,12 +251,11 @@ def test_no_pattern_support(func, opt, pattern): def test_add_url_benchmark(values, benchmark): - blocked_hosts = os.path.join(utils.abs_datapath(), 'blocked-hosts') + blocked_hosts = list(utils.blocked_hosts()) def _add_blocked(): - with open(blocked_hosts, 'r', encoding='utf-8') as f: - for line in f: - values.add(False, urlmatch.UrlPattern(line)) + for line in blocked_hosts: + values.add(False, urlmatch.UrlPattern(line)) benchmark(_add_blocked) @@ -268,12 +266,10 @@ def test_add_url_benchmark(values, benchmark): 'http://bop.foo.bar.baz/', ]) def test_domain_lookup_sparse_benchmark(url, values, benchmark): - blocked_hosts = os.path.join(utils.abs_datapath(), 'blocked-hosts') url = QUrl(url) values.add(False, urlmatch.UrlPattern("*.foo.bar.baz")) - with open(blocked_hosts, 'r', encoding='utf-8') as f: - for line in f: - values.add(False, urlmatch.UrlPattern(line)) + for line in utils.blocked_hosts(): + values.add(False, urlmatch.UrlPattern(line)) benchmark(lambda: values.get_for_url(url)) |