diff --git a/tests/test_utils.py b/tests/test_utils.py index 6c288c2a..e704e15f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,7 @@ +# -*- coding: utf-8 -*- + import pytest +import warnings from mock import Mock import six from thefuck.utils import default_settings, \ @@ -233,11 +236,17 @@ class TestCompatibilityCall(object): class TestGetValidHistoryWithoutCurrent(object): + @pytest.yield_fixture(autouse=True) + def fail_on_warning(self): + warnings.simplefilter('error') + yield + warnings.resetwarnings() + @pytest.fixture(autouse=True) def history(self, mocker): return mocker.patch('thefuck.shells.shell.get_history', return_value=['le cat', 'fuck', 'ls cat', - 'diff x', 'nocommand x']) + 'diff x', 'nocommand x', u'café ô']) @pytest.fixture(autouse=True) def alias(self, mocker): @@ -255,11 +264,12 @@ class TestGetValidHistoryWithoutCurrent(object): path_mock = mocker.Mock(iterdir=mocker.Mock(return_value=callables)) return mocker.patch('thefuck.utils.Path', return_value=path_mock) - @pytest.mark.parametrize('script, result', [ - ('le cat', ['ls cat', 'diff x']), - ('diff x', ['ls cat']), - ('fuck', ['ls cat', 'diff x'])]) + ('le cat', ['ls cat', 'diff x', u'café ô']), + ('diff x', ['ls cat', u'café ô']), + ('fuck', ['ls cat', 'diff x', u'café ô']), + (u'cafe ô', ['ls cat', 'diff x', u'café ô']), + ]) def test_get_valid_history_without_current(self, script, result): command = Command(script=script) assert get_valid_history_without_current(command) == result diff --git a/thefuck/utils.py b/thefuck/utils.py index 83079e34..1f9a4021 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -110,7 +110,7 @@ def get_all_executables(): tf_entry_points = get_installation_info().get_entry_map()\ .get('console_scripts', {})\ .keys() - bins = [exe.name + bins = [exe.name.decode('utf8') if six.PY2 else exe.name for path in os.environ.get('PATH', '').split(':') for exe in _safe(lambda: list(Path(path).iterdir()), []) if not _safe(exe.is_dir, True)