extended tests to cover new file argument
This commit is contained in:
parent
362db3d986
commit
9a889c6866
@ -1256,12 +1256,21 @@ class TestRegexList:
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
|
||||
|
||||
def unrequired_class(**kwargs):
|
||||
return configtypes.File(required=False, **kwargs)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('qapp')
|
||||
class TestFileAndUserStyleSheet:
|
||||
|
||||
"""Test File/UserStyleSheet."""
|
||||
|
||||
@pytest.fixture(params=[configtypes.File, configtypes.UserStyleSheet])
|
||||
@pytest.fixture(params=[
|
||||
configtypes.File,
|
||||
configtypes.UserStyleSheet,
|
||||
unrequired_class,
|
||||
])
|
||||
def klass(self, request):
|
||||
return request.param
|
||||
|
||||
@ -1281,6 +1290,8 @@ class TestFileAndUserStyleSheet:
|
||||
return arg
|
||||
elif klass is configtypes.UserStyleSheet:
|
||||
return QUrl.fromLocalFile(arg)
|
||||
elif klass is unrequired_class:
|
||||
return arg
|
||||
else:
|
||||
assert False, klass
|
||||
|
||||
@ -1297,6 +1308,11 @@ class TestFileAndUserStyleSheet:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
configtypes.File().validate('foobar')
|
||||
|
||||
def test_validate_does_not_exist_optional_file(self, os_mock):
|
||||
"""Test validate with a file which does not exist (File)."""
|
||||
os_mock.path.isfile.return_value = False
|
||||
configtypes.File(required=False).validate('foobar')
|
||||
|
||||
def test_validate_does_not_exist_userstylesheet(self, os_mock):
|
||||
"""Test validate with a file which does not exist (UserStyleSheet)."""
|
||||
os_mock.path.isfile.return_value = False
|
||||
@ -1331,7 +1347,9 @@ class TestFileAndUserStyleSheet:
|
||||
(configtypes.File(), 'foobar', True),
|
||||
(configtypes.UserStyleSheet(), 'foobar', False),
|
||||
(configtypes.UserStyleSheet(), '\ud800', True),
|
||||
], ids=['file-foobar', 'userstylesheet-foobar', 'userstylesheet-unicode'])
|
||||
(configtypes.File(required=False), 'foobar', False),
|
||||
], ids=['file-foobar', 'userstylesheet-foobar', 'userstylesheet-unicode',
|
||||
'file-optional-foobar'])
|
||||
def test_validate_rel_inexistent(self, os_mock, monkeypatch, configtype,
|
||||
value, raises):
|
||||
"""Test with a relative path and standarddir.config returning None."""
|
||||
|
Loading…
Reference in New Issue
Block a user