Fix tests for basedir logging.

f5febc4 broke various tests which called standarddir.init() without a valid
basedir.
This commit is contained in:
Florian Bruhin 2015-11-29 00:23:39 +01:00
parent a67644589e
commit 6a46aea934
3 changed files with 12 additions and 7 deletions

View File

@ -190,7 +190,9 @@ def _maybe_create(path):
def init(args):
"""Initialize all standard dirs."""
global _args
log.init.debug("Base directory: {}".format(args.basedir))
if args is not None:
# args can be None during tests
log.init.debug("Base directory: {}".format(args.basedir))
_args = args
_init_cachedir_tag()

View File

@ -315,7 +315,8 @@ class TestConfigInit:
def test_config_none(self, monkeypatch):
"""Test initializing with config path set to None."""
args = types.SimpleNamespace(confdir='', datadir='', cachedir='')
args = types.SimpleNamespace(confdir='', datadir='', cachedir='',
basedir='')
for k, v in self.env.items():
monkeypatch.setenv(k, v)
standarddir.init(args)

View File

@ -177,27 +177,28 @@ class TestArguments:
def test_confdir(self, testcase):
"""Test --confdir."""
args = types.SimpleNamespace(confdir=testcase.arg, cachedir=None,
datadir=None)
datadir=None, basedir=None)
standarddir.init(args)
assert standarddir.config() == testcase.expected
def test_cachedir(self, testcase):
"""Test --cachedir."""
args = types.SimpleNamespace(confdir=None, cachedir=testcase.arg,
datadir=None)
datadir=None, basedir=None)
standarddir.init(args)
assert standarddir.cache() == testcase.expected
def test_datadir(self, testcase):
"""Test --datadir."""
args = types.SimpleNamespace(confdir=None, cachedir=None,
datadir=testcase.arg)
datadir=testcase.arg, basedir=None)
standarddir.init(args)
assert standarddir.data() == testcase.expected
def test_confdir_none(self):
"""Test --confdir with None given."""
args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None)
args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None,
basedir=None)
standarddir.init(args)
assert standarddir.config().split(os.sep)[-1] == 'qute_test'
@ -206,7 +207,8 @@ class TestArguments:
monkeypatch.setattr(
'qutebrowser.utils.standarddir.QStandardPaths.writableLocation',
lambda _typ: str(tmpdir))
args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None)
args = types.SimpleNamespace(confdir=None, cachedir=None, datadir=None,
basedir=None)
standarddir.init(args)
assert standarddir.runtime() == str(tmpdir / 'qute_test')