tests: Move fake_save_manager to helper.fixtures

This commit is contained in:
Florian Bruhin 2016-06-09 13:01:50 +02:00
parent ef2b3cd6d9
commit 75669dd21b
2 changed files with 11 additions and 10 deletions

View File

@ -36,6 +36,7 @@ import helpers.stubs as stubsmod
from qutebrowser.config import config
from qutebrowser.utils import objreg
from qutebrowser.browser import cookies
from qutebrowser.misc import savemanager
from PyQt5.QtCore import QEvent, QSize, Qt
from PyQt5.QtGui import QKeyEvent
@ -303,3 +304,12 @@ def py_proc():
return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))])
return func
@pytest.yield_fixture
def fake_save_manager():
"""Create a mock of save-manager and register it into objreg."""
fake_save_manager = unittest.mock.Mock(spec=savemanager.SaveManager)
objreg.register('save-manager', fake_save_manager)
yield
objreg.delete('save-manager')

View File

@ -27,7 +27,7 @@ import pytest
from qutebrowser.browser import cookies
from qutebrowser.utils import objreg
from qutebrowser.misc import lineparser, savemanager
from qutebrowser.misc import lineparser
CONFIG_ALL_COOKIES = {'content': {'cookies-accept': 'all'}}
CONFIG_NEVER_COOKIES = {'content': {'cookies-accept': 'never'}}
@ -67,15 +67,6 @@ class LineparserSaveStub(lineparser.BaseLineParser):
return self.data[key]
@pytest.yield_fixture
def fake_save_manager():
"""Create a mock of save-manager and register it into objreg."""
fake_save_manager = mock.Mock(spec=savemanager.SaveManager)
objreg.register('save-manager', fake_save_manager)
yield
objreg.delete('save-manager')
def test_set_cookies_accept(config_stub, qtbot, monkeypatch):
"""Test setCookiesFromUrl with cookies enabled."""
config_stub.data = CONFIG_ALL_COOKIES