1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-29 22:24:44 +00:00

#540: Fix code style, add test

This commit is contained in:
Vladimir Iakovlev
2016-08-22 05:45:27 +03:00
parent 1a4d74d487
commit afd2ed4e51
2 changed files with 31 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
import pytest
import six
import os
from mock import Mock
from thefuck import const
@@ -101,3 +102,22 @@ class TestInitializeSettingsFile(object):
for setting in const.DEFAULT_SETTINGS.items():
assert '# {} = {}\n'.format(*setting) in settings_file_contents
settings_file.close()
@pytest.mark.parametrize('legacy_dir_exists, xdg_config_home, result', [
(False, '~/.config', '~/.config/thefuck'),
(False, '/user/test/config/', '/user/test/config/thefuck'),
(True, '~/.config', '~/.thefuck'),
(True, '/user/test/config/', '~/.thefuck')])
def test_get_user_dir_path(mocker, environ, settings, legacy_dir_exists,
xdg_config_home, result):
mocker.patch('thefuck.conf.Path.is_dir',
return_value=legacy_dir_exists)
if xdg_config_home is not None:
environ['XDG_CONFIG_HOME'] = xdg_config_home
else:
environ.pop('XDG_CONFIG_HOME', None)
path = settings._get_user_dir_path().as_posix()
assert path == os.path.expanduser(result)