Fix HostBlocker.on_config_changed with no datadir
This commit is contained in:
parent
6d1764e732
commit
4403f02ac5
@ -116,7 +116,7 @@ class HostBlocker:
|
||||
self._local_hosts_file = None
|
||||
else:
|
||||
self._local_hosts_file = os.path.join(data_dir, 'blocked-hosts')
|
||||
self.on_config_changed()
|
||||
self.on_config_changed()
|
||||
|
||||
config_dir = standarddir.config()
|
||||
if config_dir is None:
|
||||
@ -274,7 +274,7 @@ class HostBlocker:
|
||||
def on_config_changed(self):
|
||||
"""Update files when the config changed."""
|
||||
urls = config.get('content', 'host-block-lists')
|
||||
if urls is None:
|
||||
if urls is None and self._local_hosts_file is not None:
|
||||
try:
|
||||
os.remove(self._local_hosts_file)
|
||||
except FileNotFoundError:
|
||||
|
@ -258,6 +258,9 @@ def test_without_datadir(config_stub, tmpdir, monkeypatch, win_registry):
|
||||
for str_url in URLS_TO_CHECK:
|
||||
assert not host_blocker.is_blocked(QUrl(str_url))
|
||||
|
||||
# To test on_config_changed
|
||||
config_stub.set('content', 'host-block-lists', None)
|
||||
|
||||
|
||||
def test_disabled_blocking_update(basedir, config_stub, download_stub,
|
||||
data_tmpdir, tmpdir, win_registry):
|
||||
|
Loading…
Reference in New Issue
Block a user