Skip standarddir migrations when a basedir is given
This commit is contained in:
parent
3dc67df180
commit
0de7b2eb83
@ -266,7 +266,7 @@ def init(args):
|
|||||||
|
|
||||||
_init_dirs(args)
|
_init_dirs(args)
|
||||||
_init_cachedir_tag()
|
_init_cachedir_tag()
|
||||||
if args is not None:
|
if args is not None and getattr(args, 'basedir', None) is None:
|
||||||
_move_webengine_data()
|
_move_webengine_data()
|
||||||
if sys.platform == 'darwin': # pragma: no cover
|
if sys.platform == 'darwin': # pragma: no cover
|
||||||
_move_macos()
|
_move_macos()
|
||||||
|
@ -475,8 +475,8 @@ class TestDataMigrations:
|
|||||||
'qutebrowser.conf').exists()
|
'qutebrowser.conf').exists()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('with_args', [True, False])
|
@pytest.mark.parametrize('args_kind', ['basedir', 'normal', 'none'])
|
||||||
def test_init(mocker, tmpdir, with_args):
|
def test_init(mocker, tmpdir, args_kind):
|
||||||
"""Do some sanity checks for standarddir.init().
|
"""Do some sanity checks for standarddir.init().
|
||||||
|
|
||||||
Things like _init_cachedir_tag() and _move_webengine_data() are tested in
|
Things like _init_cachedir_tag() and _move_webengine_data() are tested in
|
||||||
@ -484,18 +484,21 @@ def test_init(mocker, tmpdir, with_args):
|
|||||||
"""
|
"""
|
||||||
assert standarddir._locations == {}
|
assert standarddir._locations == {}
|
||||||
|
|
||||||
if with_args:
|
|
||||||
args = types.SimpleNamespace(basedir=str(tmpdir))
|
|
||||||
m = mocker.patch('qutebrowser.utils.standarddir._move_webengine_data')
|
m = mocker.patch('qutebrowser.utils.standarddir._move_webengine_data')
|
||||||
m_windows = mocker.patch('qutebrowser.utils.standarddir._move_windows')
|
m_windows = mocker.patch('qutebrowser.utils.standarddir._move_windows')
|
||||||
m_mac = mocker.patch('qutebrowser.utils.standarddir._move_macos')
|
m_mac = mocker.patch('qutebrowser.utils.standarddir._move_macos')
|
||||||
|
if args_kind == 'normal':
|
||||||
|
args = types.SimpleNamespace(basedir=None)
|
||||||
|
elif args_kind == 'basedir':
|
||||||
|
args = types.SimpleNamespace(basedir=str(tmpdir))
|
||||||
else:
|
else:
|
||||||
|
assert args_kind == 'none'
|
||||||
args = None
|
args = None
|
||||||
|
|
||||||
standarddir.init(args)
|
standarddir.init(args)
|
||||||
|
|
||||||
assert standarddir._locations != {}
|
assert standarddir._locations != {}
|
||||||
if with_args:
|
if args_kind == 'normal':
|
||||||
assert m.called
|
assert m.called
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
assert not m_windows.called
|
assert not m_windows.called
|
||||||
@ -506,6 +509,10 @@ def test_init(mocker, tmpdir, with_args):
|
|||||||
else:
|
else:
|
||||||
assert not m_windows.called
|
assert not m_windows.called
|
||||||
assert not m_mac.called
|
assert not m_mac.called
|
||||||
|
else:
|
||||||
|
assert not m.called
|
||||||
|
assert not m_windows.called
|
||||||
|
assert not m_mac.called
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.linux
|
@pytest.mark.linux
|
||||||
|
Loading…
Reference in New Issue
Block a user