This commit is contained in:
Florian Bruhin 2016-06-09 17:25:52 +02:00
parent d5abfa3d0d
commit 33f01d8375
4 changed files with 4 additions and 8 deletions

View File

@ -68,6 +68,7 @@ class Entry:
@classmethod @classmethod
def from_str(cls, line): def from_str(cls, line):
"""Parse a history line like '12345 http://example.com title'."""
data = line.split(maxsplit=2) data = line.split(maxsplit=2)
if len(data) == 2: if len(data) == 2:
atime, url = data atime, url = data
@ -210,7 +211,7 @@ class WebHistory(QObject):
self._initial_read_done = True self._initial_read_done = True
self.async_read_done.emit() self.async_read_done.emit()
for url, entry in self._temp_history.items(): for entry in self._temp_history.values():
self._add_entry(entry) self._add_entry(entry)
if not entry.hidden: if not entry.hidden:
self._new_history.append(entry) self._new_history.append(entry)
@ -272,7 +273,6 @@ class WebHistory(QObject):
self._add_entry(entry, target=self._temp_history) self._add_entry(entry, target=self._temp_history)
def init(parent=None): def init(parent=None):
"""Initialize the web history. """Initialize the web history.

View File

@ -266,7 +266,6 @@ def webframe(webpage):
@pytest.fixture @pytest.fixture
def fake_keyevent_factory(): def fake_keyevent_factory():
"""Fixture that when called will return a mock instance of a QKeyEvent.""" """Fixture that when called will return a mock instance of a QKeyEvent."""
def fake_keyevent(key, modifiers=0, text='', typ=QEvent.KeyPress): def fake_keyevent(key, modifiers=0, text='', typ=QEvent.KeyPress):
"""Generate a new fake QKeyPressEvent.""" """Generate a new fake QKeyPressEvent."""
evtmock = unittest.mock.create_autospec(QKeyEvent, instance=True) evtmock = unittest.mock.create_autospec(QKeyEvent, instance=True)

View File

@ -19,14 +19,11 @@
"""Tests for qutebrowser.browser.cookies.""" """Tests for qutebrowser.browser.cookies."""
from unittest import mock
from PyQt5.QtNetwork import QNetworkCookie from PyQt5.QtNetwork import QNetworkCookie
from PyQt5.QtCore import QUrl from PyQt5.QtCore import QUrl
import pytest import pytest
from qutebrowser.browser import cookies from qutebrowser.browser import cookies
from qutebrowser.utils import objreg
from qutebrowser.misc import lineparser from qutebrowser.misc import lineparser
CONFIG_ALL_COOKIES = {'content': {'cookies-accept': 'all'}} CONFIG_ALL_COOKIES = {'content': {'cookies-accept': 'all'}}

View File

@ -38,7 +38,6 @@ def test_init(hist, fake_save_manager):
def test_adding_item_during_async_read(qtbot, hist): def test_adding_item_during_async_read(qtbot, hist):
"""Check what happens when adding URL while reading the history.""" """Check what happens when adding URL while reading the history."""
with qtbot.assertNotEmitted(hist.add_completion_item), \ with qtbot.assertNotEmitted(hist.add_completion_item), \
qtbot.assertNotEmitted(hist.item_added): qtbot.assertNotEmitted(hist.item_added):
hist.add_url(QUrl('http://www.example.com/')) hist.add_url(QUrl('http://www.example.com/'))
@ -56,7 +55,8 @@ def test_adding_item_during_async_read(qtbot, hist):
def test_private_browsing(qtbot, tmpdir, fake_save_manager, config_stub): def test_private_browsing(qtbot, tmpdir, fake_save_manager, config_stub):
"""Make sure no data is saved at all with private browsing.""" """Make sure no data is saved at all with private browsing."""
config_stub.data = {'general': {'private-browsing': True}} config_stub.data = {'general': {'private-browsing': True}}
private_hist = history.WebHistory(hist_dir=str(tmpdir), hist_name='history') private_hist = history.WebHistory(hist_dir=str(tmpdir),
hist_name='history')
# Before initial read # Before initial read
with qtbot.assertNotEmitted(private_hist.add_completion_item), \ with qtbot.assertNotEmitted(private_hist.add_completion_item), \