parent
beb970d7d5
commit
98d1fca220
@ -378,10 +378,10 @@ class TestIsEditable:
|
|||||||
webelem.config = old_config
|
webelem.config = old_config
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def stubbed_config(self, config_stub, mocker):
|
def stubbed_config(self, config_stub, monkeypatch):
|
||||||
"""Fixture to create a config stub with an input section."""
|
"""Fixture to create a config stub with an input section."""
|
||||||
config_stub.data = {'input': {}}
|
config_stub.data = {'input': {}}
|
||||||
mocker.patch('qutebrowser.browser.webelem.config', new=config_stub)
|
monkeypatch.setattr('qutebrowser.browser.webelem.config', config_stub)
|
||||||
return config_stub
|
return config_stub
|
||||||
|
|
||||||
def test_input_plain(self):
|
def test_input_plain(self):
|
||||||
|
@ -883,11 +883,12 @@ class TestCommand:
|
|||||||
"""Test Command."""
|
"""Test Command."""
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs):
|
def setup(self, monkeypatch, stubs):
|
||||||
self.t = configtypes.Command()
|
self.t = configtypes.Command()
|
||||||
cmd_utils = stubs.FakeCmdUtils({'cmd1': stubs.FakeCommand("desc 1"),
|
cmd_utils = stubs.FakeCmdUtils({'cmd1': stubs.FakeCommand("desc 1"),
|
||||||
'cmd2': stubs.FakeCommand("desc 2")})
|
'cmd2': stubs.FakeCommand("desc 2")})
|
||||||
mocker.patch('qutebrowser.config.configtypes.cmdutils', new=cmd_utils)
|
monkeypatch.setattr('qutebrowser.config.configtypes.cmdutils',
|
||||||
|
cmd_utils)
|
||||||
|
|
||||||
def test_validate_empty(self):
|
def test_validate_empty(self):
|
||||||
"""Test validate with an empty string."""
|
"""Test validate with an empty string."""
|
||||||
|
@ -55,10 +55,10 @@ def fake_keyconfig():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_timer(mocker, stubs):
|
def mock_timer(monkeypatch, stubs):
|
||||||
"""Mock the Timer class used by the usertypes module with a stub."""
|
"""Mock the Timer class used by the usertypes module with a stub."""
|
||||||
mocker.patch('qutebrowser.keyinput.basekeyparser.usertypes.Timer',
|
monkeypatch.setattr('qutebrowser.keyinput.basekeyparser.usertypes.Timer',
|
||||||
new=stubs.FakeTimer)
|
stubs.FakeTimer)
|
||||||
|
|
||||||
|
|
||||||
class TestSplitCount:
|
class TestSplitCount:
|
||||||
@ -206,11 +206,11 @@ class TestKeyChain:
|
|||||||
assert self.kp._keystring == ''
|
assert self.kp._keystring == ''
|
||||||
|
|
||||||
def test_ambiguous_keychain(self, fake_keyevent_factory, config_stub,
|
def test_ambiguous_keychain(self, fake_keyevent_factory, config_stub,
|
||||||
mocker):
|
monkeypatch):
|
||||||
"""Test ambiguous keychain."""
|
"""Test ambiguous keychain."""
|
||||||
config_stub.data = CONFIG
|
config_stub.data = CONFIG
|
||||||
mocker.patch('qutebrowser.keyinput.basekeyparser.config',
|
monkeypatch.setattr('qutebrowser.keyinput.basekeyparser.config',
|
||||||
new=config_stub)
|
config_stub)
|
||||||
timer = self.kp._ambiguous_timer
|
timer = self.kp._ambiguous_timer
|
||||||
assert not timer.isActive()
|
assert not timer.isActive()
|
||||||
# We start with 'a' where the keychain gives us an ambiguous result.
|
# We start with 'a' where the keychain gives us an ambiguous result.
|
||||||
|
@ -49,13 +49,14 @@ class TestsNormalKeyParser:
|
|||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
"""Set up mocks and read the test config."""
|
"""Set up mocks and read the test config."""
|
||||||
mocker.patch('qutebrowser.keyinput.basekeyparser.usertypes.Timer',
|
monkeypatch.setattr(
|
||||||
new=stubs.FakeTimer)
|
'qutebrowser.keyinput.basekeyparser.usertypes.Timer',
|
||||||
|
stubs.FakeTimer)
|
||||||
config_stub.data = CONFIG
|
config_stub.data = CONFIG
|
||||||
mocker.patch('qutebrowser.keyinput.modeparsers.config',
|
monkeypatch.setattr('qutebrowser.keyinput.modeparsers.config',
|
||||||
new=config_stub)
|
config_stub)
|
||||||
|
|
||||||
objreg.register('key-config', fake_keyconfig)
|
objreg.register('key-config', fake_keyconfig)
|
||||||
self.kp = modeparsers.NormalKeyParser(0)
|
self.kp = modeparsers.NormalKeyParser(0)
|
||||||
|
@ -41,18 +41,18 @@ class TestArg:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs):
|
def setup(self, monkeypatch, stubs):
|
||||||
mocker.patch('qutebrowser.misc.editor.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.QProcess',
|
||||||
new_callable=stubs.FakeQProcess)
|
stubs.FakeQProcess())
|
||||||
self.editor = editor.ExternalEditor(0)
|
self.editor = editor.ExternalEditor(0)
|
||||||
yield
|
yield
|
||||||
self.editor._cleanup() # pylint: disable=protected-access
|
self.editor._cleanup() # pylint: disable=protected-access
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def stubbed_config(self, config_stub, mocker):
|
def stubbed_config(self, config_stub, monkeypatch):
|
||||||
"""Fixture to create a config stub with an input section."""
|
"""Fixture to create a config stub with an input section."""
|
||||||
config_stub.data = {'input': {}}
|
config_stub.data = {'input': {}}
|
||||||
mocker.patch('qutebrowser.misc.editor.config', new=config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
return config_stub
|
return config_stub
|
||||||
|
|
||||||
def test_simple_start_args(self, stubbed_config):
|
def test_simple_start_args(self, stubbed_config):
|
||||||
@ -98,14 +98,14 @@ class TestFileHandling:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
mocker.patch('qutebrowser.misc.editor.message',
|
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
||||||
new=stubs.MessageModule())
|
stubs.MessageModule())
|
||||||
mocker.patch('qutebrowser.misc.editor.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.QProcess',
|
||||||
new_callable=stubs.FakeQProcess)
|
stubs.FakeQProcess())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
'editor-encoding': 'utf-8'}}
|
'editor-encoding': 'utf-8'}}
|
||||||
mocker.patch('qutebrowser.misc.editor.config', config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
self.editor = editor.ExternalEditor(0)
|
self.editor = editor.ExternalEditor(0)
|
||||||
|
|
||||||
def test_file_handling_closed_ok(self):
|
def test_file_handling_closed_ok(self):
|
||||||
@ -147,12 +147,12 @@ class TestModifyTests:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
mocker.patch('qutebrowser.misc.editor.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.QProcess',
|
||||||
new_callable=stubs.FakeQProcess)
|
stubs.FakeQProcess())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
'editor-encoding': 'utf-8'}}
|
'editor-encoding': 'utf-8'}}
|
||||||
mocker.patch('qutebrowser.misc.editor.config', new=config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
self.editor = editor.ExternalEditor(0)
|
self.editor = editor.ExternalEditor(0)
|
||||||
self.editor.editing_finished = mock.Mock()
|
self.editor.editing_finished = mock.Mock()
|
||||||
|
|
||||||
@ -219,14 +219,14 @@ class TestErrorMessage:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture(autouse=True)
|
||||||
def setup(self, mocker, stubs, config_stub):
|
def setup(self, monkeypatch, stubs, config_stub):
|
||||||
mocker.patch('qutebrowser.misc.editor.QProcess',
|
monkeypatch.setattr('qutebrowser.misc.editor.QProcess',
|
||||||
new_callable=stubs.FakeQProcess)
|
stubs.FakeQProcess())
|
||||||
mocker.patch('qutebrowser.misc.editor.message',
|
monkeypatch.setattr('qutebrowser.misc.editor.message',
|
||||||
new=stubs.MessageModule())
|
stubs.MessageModule())
|
||||||
config_stub.data = {'general': {'editor': [''],
|
config_stub.data = {'general': {'editor': [''],
|
||||||
'editor-encoding': 'utf-8'}}
|
'editor-encoding': 'utf-8'}}
|
||||||
mocker.patch('qutebrowser.misc.editor.config', new=config_stub)
|
monkeypatch.setattr('qutebrowser.misc.editor.config', config_stub)
|
||||||
self.editor = editor.ExternalEditor(0)
|
self.editor = editor.ExternalEditor(0)
|
||||||
yield
|
yield
|
||||||
self.editor._cleanup() # pylint: disable=protected-access
|
self.editor._cleanup() # pylint: disable=protected-access
|
||||||
|
@ -31,10 +31,11 @@ from qutebrowser.misc import readline
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mocked_qapp(mocker, stubs):
|
def mocked_qapp(monkeypatch, stubs):
|
||||||
"""Fixture that mocks readline.QApplication and returns it."""
|
"""Fixture that mocks readline.QApplication and returns it."""
|
||||||
return mocker.patch('qutebrowser.misc.readline.QApplication',
|
stub = stubs.FakeQApplication()
|
||||||
new_callable=stubs.FakeQApplication)
|
monkeypatch.setattr('qutebrowser.misc.readline.QApplication', stub)
|
||||||
|
return stub
|
||||||
|
|
||||||
|
|
||||||
class TestNoneWidget:
|
class TestNoneWidget:
|
||||||
|
@ -81,10 +81,10 @@ class TestSearchUrl:
|
|||||||
"""Test _get_search_url."""
|
"""Test _get_search_url."""
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_config(self, config_stub, mocker):
|
def mock_config(self, config_stub, monkeypatch):
|
||||||
"""Fixture to patch urlutils.config with a stub."""
|
"""Fixture to patch urlutils.config with a stub."""
|
||||||
init_config_stub(config_stub)
|
init_config_stub(config_stub)
|
||||||
mocker.patch('qutebrowser.utils.urlutils.config', config_stub)
|
monkeypatch.setattr('qutebrowser.utils.urlutils.config', config_stub)
|
||||||
|
|
||||||
def test_default_engine(self):
|
def test_default_engine(self):
|
||||||
"""Test default search engine."""
|
"""Test default search engine."""
|
||||||
@ -159,24 +159,24 @@ class TestIsUrl:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.parametrize('url', URLS)
|
@pytest.mark.parametrize('url', URLS)
|
||||||
def test_urls(self, mocker, config_stub, url):
|
def test_urls(self, monkeypatch, config_stub, url):
|
||||||
"""Test things which are URLs."""
|
"""Test things which are URLs."""
|
||||||
init_config_stub(config_stub, 'naive')
|
init_config_stub(config_stub, 'naive')
|
||||||
mocker.patch('qutebrowser.utils.urlutils.config', config_stub)
|
monkeypatch.setattr('qutebrowser.utils.urlutils.config', config_stub)
|
||||||
assert urlutils.is_url(url), url
|
assert urlutils.is_url(url), url
|
||||||
|
|
||||||
@pytest.mark.parametrize('url', NOT_URLS)
|
@pytest.mark.parametrize('url', NOT_URLS)
|
||||||
def test_not_urls(self, mocker, config_stub, url):
|
def test_not_urls(self, monkeypatch, config_stub, url):
|
||||||
"""Test things which are not URLs."""
|
"""Test things which are not URLs."""
|
||||||
init_config_stub(config_stub, 'naive')
|
init_config_stub(config_stub, 'naive')
|
||||||
mocker.patch('qutebrowser.utils.urlutils.config', config_stub)
|
monkeypatch.setattr('qutebrowser.utils.urlutils.config', config_stub)
|
||||||
assert not urlutils.is_url(url), url
|
assert not urlutils.is_url(url), url
|
||||||
|
|
||||||
@pytest.mark.parametrize('autosearch', [True, False])
|
@pytest.mark.parametrize('autosearch', [True, False])
|
||||||
def test_search_autosearch(self, mocker, config_stub, autosearch):
|
def test_search_autosearch(self, monkeypatch, config_stub, autosearch):
|
||||||
"""Test explicit search with auto-search=True."""
|
"""Test explicit search with auto-search=True."""
|
||||||
init_config_stub(config_stub, autosearch)
|
init_config_stub(config_stub, autosearch)
|
||||||
mocker.patch('qutebrowser.utils.urlutils.config', config_stub)
|
monkeypatch.setattr('qutebrowser.utils.urlutils.config', config_stub)
|
||||||
assert not urlutils.is_url('test foo')
|
assert not urlutils.is_url('test foo')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user