From f5d299d8c7170061406fa89020183a2762a2e1ef Mon Sep 17 00:00:00 2001 From: Lamar Pavel Date: Thu, 28 May 2015 13:05:12 +0200 Subject: [PATCH] Fix intents --- qutebrowser/config/configtypes.py | 10 +++++----- tests/config/test_configtypes.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index edc96d89d..489dc456d 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -820,12 +820,12 @@ class File(BaseType): value = os.path.expanduser(value) try: if not os.path.isabs(value): - if standarddir.config(): - if os.path.isfile( - os.path.join(standarddir.config(), value)): - return + cfgdir = standarddir.config() + if cfgdir: + if os.path.isfile(os.path.join(cfgdir, value)): + return raise configexc.ValidationError(value, - "must be an absolute path!") + "must be an absolute path!") if not os.path.isfile(value): raise configexc.ValidationError(value, "must be a valid file!") except UnicodeEncodeError as e: diff --git a/tests/config/test_configtypes.py b/tests/config/test_configtypes.py index 1d52afdc8..317acbe5e 100644 --- a/tests/config/test_configtypes.py +++ b/tests/config/test_configtypes.py @@ -30,7 +30,7 @@ from PyQt5.QtGui import QColor, QFont from PyQt5.QtNetwork import QNetworkProxy from qutebrowser.config import configtypes, configexc -from qutebrowser.utils import debug, utils, standarddir +from qutebrowser.utils import debug, utils class Font(QFont): @@ -1375,19 +1375,19 @@ class TestFile: def test_validate_exists_rel(self, os_path, monkeypatch): """Test validate with a relative path to an existing file.""" - monkeypatch.setattr('qutebrowser.config.configtypes.standarddir.config', - lambda: '/home/foo/.config/') + monkeypatch.setattr( + 'qutebrowser.config.configtypes.standarddir.config', + lambda: '/home/foo/.config/') os_path.expanduser.side_effect = lambda x: x os_path.isfile.return_value = True os_path.isabs.return_value = False self.t.validate('foobar') - os_path.join.assert_called_once_with('/home/foo/.config/', - 'foobar') + os_path.join.assert_called_once_with('/home/foo/.config/', 'foobar') def test_validate_rel_config_none(self, os_path, monkeypatch): """Test with a relative path and standarddir.config returning None.""" - monkeypatch.setattr('qutebrowser.config.configtypes.standarddir.config', - lambda: None) + monkeypatch.setattr( + 'qutebrowser.config.configtypes.standarddir.config', lambda: None) os_path.isabs.return_value = False with pytest.raises(configexc.ValidationError): self.t.validate('foobar')