From 88d92db6e4cfc6ca5e0880636b833c7b263fc980 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 11 Aug 2015 20:15:55 +0200 Subject: [PATCH] Add tests for rel. inexistent File/UserStyleSheet. --- tests/config/test_configtypes.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/config/test_configtypes.py b/tests/config/test_configtypes.py index 35ada44ab..e232b496c 100644 --- a/tests/config/test_configtypes.py +++ b/tests/config/test_configtypes.py @@ -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: