def test_two_active_items(): """Check tabhistory.serialize with two active items.""" items = [Item(QUrl(), '', active=True), Item(QUrl(), ''), Item(QUrl(), '', active=True)] with pytest.raises(ValueError): tabhistory.serialize(items)
def test_utf_8_invalid(self, tmpdir, sess_man, fake_history): """Make sure data containing invalid UTF8 raises SessionError.""" session_path = tmpdir / 'foo.yml' fake_history( [Item(QUrl('http://www.qutebrowser.org/'), '\ud800', active=True)]) try: sess_man.save(str(session_path)) except sessions.SessionError: # This seems to happen on some systems only?! pass else: data = session_path.read_text('utf-8') assert r'title: "\uD800"' in data
def test_no_active_item(): """Check tabhistory.serialize with no active item.""" items = [Item(QUrl(), '')] with pytest.raises(ValueError): tabhistory.serialize(items)
"""Tests for webelement.tabhistory.""" import attr from PyQt5.QtCore import QUrl, QPoint import pytest tabhistory = pytest.importorskip('qutebrowser.browser.webkit.tabhistory') from qutebrowser.misc.sessions import TabHistoryItem as Item from qutebrowser.utils import qtutils pytestmark = pytest.mark.qt_log_ignore('QIODevice::read.*: device not open') ITEMS = [ Item(QUrl('https://www.heise.de/'), 'heise'), Item(QUrl('http://example.com/%E2%80%A6'), 'percent', active=True), Item(QUrl('http://example.com/?foo=bar'), 'arg', original_url=QUrl('http://original.url.example.com/'), user_data={'foo': 23, 'bar': 42}), # From https://github.com/OtterBrowser/otter-browser/issues/709#issuecomment-74749471 Item(QUrl('http://github.com/OtterBrowser/24/134/2344/otter-browser/' 'issues/709/'), 'Page not found | github', user_data={'zoom': 149, 'scroll-pos': QPoint(0, 0)}), Item(QUrl('https://mail.google.com/mail/u/0/#label/some+label/' '234lkjsd0932lkjf884jqwerdf4'), '"some label" - [email protected] - Gmail"', user_data={'zoom': 120, 'scroll-pos': QPoint(0, 0)}), ]