Update config tests for pattern changes

This commit is contained in:
Florian Bruhin 2018-03-06 13:26:22 +01:00
parent e1a03929e3
commit db7ccb0434
2 changed files with 10 additions and 8 deletions

View File

@ -107,9 +107,10 @@ class TestSet:
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit) monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
option = 'content.javascript.enabled' option = 'content.javascript.enabled'
with pytest.raises(cmdexc.CommandError, with pytest.raises(
match='Error while parsing :/: No scheme given'): cmdexc.CommandError,
commands.set(0, option, 'false', pattern=':/') match='Error while parsing http://: Pattern without host'):
commands.set(0, option, 'false', pattern='http://')
def test_set_no_pattern(self, monkeypatch, commands): def test_set_no_pattern(self, monkeypatch, commands):
"""Run ':set --pattern=*://* colors.statusbar.normal.bg #abcdef. """Run ':set --pattern=*://* colors.statusbar.normal.bg #abcdef.

View File

@ -301,7 +301,8 @@ class TestYaml:
('settings: {"content.images": 42}\nconfig_version: 2', ('settings: {"content.images": 42}\nconfig_version: 2',
"While parsing 'content.images'", "value is not a dict"), "While parsing 'content.images'", "value is not a dict"),
('settings: {"content.images": {"https://": true}}\nconfig_version: 2', ('settings: {"content.images": {"https://": true}}\nconfig_version: 2',
"While parsing pattern 'https://' for 'content.images'", "Pattern without host"), "While parsing pattern 'https://' for 'content.images'",
"Pattern without host"),
('settings: {"content.images": {true: true}}\nconfig_version: 2', ('settings: {"content.images": {true: true}}\nconfig_version: 2',
"While parsing 'content.images'", "pattern is not of type string"), "While parsing 'content.images'", "pattern is not of type string"),
]) ])
@ -737,11 +738,11 @@ class TestConfigPy:
assert str(error.exception) == expected assert str(error.exception) == expected
@pytest.mark.parametrize('line, text', [ @pytest.mark.parametrize('line, text', [
('config.get("content.images", "://")', ('config.get("content.images", "http://")',
"While getting 'content.images' and parsing pattern"), "While getting 'content.images' and parsing pattern"),
('config.set("content.images", False, "://")', ('config.set("content.images", False, "http://")',
"While setting 'content.images' and parsing pattern"), "While setting 'content.images' and parsing pattern"),
('with config.pattern("://"): pass', ('with config.pattern("http://"): pass',
"Unhandled exception"), "Unhandled exception"),
]) ])
def test_invalid_pattern(self, confpy, line, text): def test_invalid_pattern(self, confpy, line, text):
@ -750,7 +751,7 @@ class TestConfigPy:
assert error.text == text assert error.text == text
assert isinstance(error.exception, urlmatch.ParseError) assert isinstance(error.exception, urlmatch.ParseError)
assert str(error.exception) == "No scheme given" assert str(error.exception) == "Pattern without host"
def test_multiple_errors(self, confpy): def test_multiple_errors(self, confpy):
confpy.write("c.foo = 42", "config.set('foo', 42)", "1/0") confpy.write("c.foo = 42", "config.set('foo', 42)", "1/0")