Add tests for rel. inexistent File/UserStyleSheet.
This commit is contained in:
parent
2980bc808e
commit
88d92db6e4
@ -23,6 +23,7 @@
|
||||
import re
|
||||
import collections
|
||||
import itertools
|
||||
import os.path
|
||||
import base64
|
||||
|
||||
import pytest
|
||||
@ -1146,6 +1147,26 @@ class TestFileAndUserStyleSheet:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
configtypes.File().validate('foobar')
|
||||
|
||||
@pytest.mark.parametrize('configtype, value, raises', [
|
||||
(configtypes.File(), 'foobar', True),
|
||||
(configtypes.UserStyleSheet(), 'foobar', False),
|
||||
(configtypes.UserStyleSheet(), '\ud800', True),
|
||||
])
|
||||
def test_validate_rel_inexistent(self, os_mock, monkeypatch, configtype,
|
||||
value, raises):
|
||||
"""Test with a relative path and standarddir.config returning None."""
|
||||
monkeypatch.setattr(
|
||||
'qutebrowser.config.configtypes.standarddir.config',
|
||||
lambda: 'this/does/not/exist')
|
||||
os_mock.path.isabs.return_value = False
|
||||
os_mock.path.isfile.side_effect = os.path.isfile
|
||||
|
||||
if raises:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
configtype.validate(value)
|
||||
else:
|
||||
configtype.validate(value)
|
||||
|
||||
def test_validate_expanduser(self, klass, os_mock):
|
||||
"""Test if validate expands the user correctly."""
|
||||
os_mock.path.isfile.side_effect = (lambda path:
|
||||
|
Loading…
Reference in New Issue
Block a user