fixing non controversial changes
This commit is contained in:
parent
7a73c0f264
commit
f22fb30ef3
@ -24,7 +24,7 @@ Module attributes:
|
|||||||
value.
|
value.
|
||||||
MINVALS: A dictionary of C/Qt types (as string) mapped to their minimum
|
MINVALS: A dictionary of C/Qt types (as string) mapped to their minimum
|
||||||
value.
|
value.
|
||||||
MAX_WORLD_ID: The highest World ID allowed in this version of QtWebEngine
|
MAX_WORLD_ID: The highest world ID allowed in this version of QtWebEngine.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ from PyQt5.QtCore import QObject
|
|||||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScriptCollection
|
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScriptCollection
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from qutebrowser.browser.webengine.webenginetab import _WebEngineScripts
|
from qutebrowser.browser.webengine import webenginetab
|
||||||
from qutebrowser.browser.greasemonkey import GreasemonkeyScript
|
from qutebrowser.browser import greasemonkey
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures('greasemonkey_manager')
|
pytestmark = pytest.mark.usefixtures('greasemonkey_manager')
|
||||||
|
|
||||||
@ -50,10 +50,10 @@ class TestWebengineScripts:
|
|||||||
|
|
||||||
def test_greasemonkey_undefined_world(self, fake_web_tab, caplog):
|
def test_greasemonkey_undefined_world(self, fake_web_tab, caplog):
|
||||||
"""Make sure scripts with non-existent worlds are rejected."""
|
"""Make sure scripts with non-existent worlds are rejected."""
|
||||||
uut = _WebEngineScripts(fake_web_tab)
|
uut = webenginetab._WebEngineScripts(fake_web_tab)
|
||||||
uut._widget = self.FakeWidget()
|
uut._widget = self.FakeWidget()
|
||||||
scripts = [
|
scripts = [
|
||||||
GreasemonkeyScript([('qute-js-world', 'Mars')], None)
|
greasemonkey.GreasemonkeyScript([('qute-js-world', 'Mars')], None)
|
||||||
]
|
]
|
||||||
|
|
||||||
with caplog.at_level(logging.ERROR, 'greasemonkey'):
|
with caplog.at_level(logging.ERROR, 'greasemonkey'):
|
||||||
@ -64,16 +64,14 @@ class TestWebengineScripts:
|
|||||||
assert "has invalid value for '@qute-js-world': Mars" in msg
|
assert "has invalid value for '@qute-js-world': Mars" in msg
|
||||||
uut._widget.scripts_mock.insert.assert_not_called()
|
uut._widget.scripts_mock.insert.assert_not_called()
|
||||||
|
|
||||||
@pytest.mark.parametrize("worldid", [
|
@pytest.mark.parametrize("worldid", [-1, 257])
|
||||||
-1, 257
|
|
||||||
])
|
|
||||||
def test_greasemonkey_out_of_range_world(self, worldid,
|
def test_greasemonkey_out_of_range_world(self, worldid,
|
||||||
fake_web_tab, caplog):
|
fake_web_tab, caplog):
|
||||||
"""Make sure scripts with out-of-range worlds are rejected."""
|
"""Make sure scripts with out-of-range worlds are rejected."""
|
||||||
uut = _WebEngineScripts(fake_web_tab)
|
uut = webenginetab._WebEngineScripts(fake_web_tab)
|
||||||
uut._widget = self.FakeWidget()
|
uut._widget = self.FakeWidget()
|
||||||
scripts = [
|
scripts = [
|
||||||
GreasemonkeyScript([('qute-js-world', worldid)], None)
|
greasemonkey.GreasemonkeyScript([('qute-js-world', worldid)], None)
|
||||||
]
|
]
|
||||||
|
|
||||||
with caplog.at_level(logging.ERROR, 'greasemonkey'):
|
with caplog.at_level(logging.ERROR, 'greasemonkey'):
|
||||||
@ -85,16 +83,14 @@ class TestWebengineScripts:
|
|||||||
assert "should be between 0 and" in msg
|
assert "should be between 0 and" in msg
|
||||||
uut._widget.scripts_mock.insert.assert_not_called()
|
uut._widget.scripts_mock.insert.assert_not_called()
|
||||||
|
|
||||||
@pytest.mark.parametrize("worldid", [
|
@pytest.mark.parametrize("worldid", [0, 10])
|
||||||
0, 10
|
|
||||||
])
|
|
||||||
def test_greasemonkey_good_worlds_are_passed(self, worldid,
|
def test_greasemonkey_good_worlds_are_passed(self, worldid,
|
||||||
fake_web_tab, caplog):
|
fake_web_tab, caplog):
|
||||||
"""Make sure scripts with valid worlds have it set."""
|
"""Make sure scripts with valid worlds have it set."""
|
||||||
uut = _WebEngineScripts(fake_web_tab)
|
uut = webenginetab._WebEngineScripts(fake_web_tab)
|
||||||
uut._widget = self.FakeWidget()
|
uut._widget = self.FakeWidget()
|
||||||
scripts = [
|
scripts = [
|
||||||
GreasemonkeyScript(
|
greasemonkey.GreasemonkeyScript(
|
||||||
[('name', 'foo'), ('qute-js-world', worldid)], None
|
[('name', 'foo'), ('qute-js-world', worldid)], None
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user