mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
#N/A: Monkeypatch pathlib on windows
This commit is contained in:
parent
176924c18d
commit
621b455334
@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from thefuck import shells
|
from thefuck import shells
|
||||||
from thefuck import conf, const
|
from thefuck import conf, const
|
||||||
from thefuck.utils import Path
|
from thefuck.system import Path
|
||||||
|
|
||||||
shells.shell = shells.Generic()
|
shells.shell = shells.Generic()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from thefuck import corrector, const
|
from thefuck import corrector, const
|
||||||
from thefuck.utils import Path
|
from thefuck.system import Path
|
||||||
from tests.utils import Rule, Command, CorrectedCommand
|
from tests.utils import Rule, Command, CorrectedCommand
|
||||||
from thefuck.corrector import get_corrected_commands, organize_commands
|
from thefuck.corrector import get_corrected_commands, organize_commands
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ class TestGetRules(object):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def glob(self, mocker):
|
def glob(self, mocker):
|
||||||
results = {}
|
results = {}
|
||||||
mocker.patch('thefuck.utils.Path.glob',
|
mocker.patch('thefuck.system.Path.glob',
|
||||||
new_callable=lambda: lambda *_: results.pop('value', []))
|
new_callable=lambda: lambda *_: results.pop('value', []))
|
||||||
return lambda value: results.update({'value': value})
|
return lambda value: results.update({'value': value})
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import pytest
|
|||||||
from tests.utils import CorrectedCommand, Rule, Command
|
from tests.utils import CorrectedCommand, Rule, Command
|
||||||
from thefuck import const
|
from thefuck import const
|
||||||
from thefuck.exceptions import EmptyCommand
|
from thefuck.exceptions import EmptyCommand
|
||||||
from thefuck.utils import Path
|
from thefuck.system import Path
|
||||||
|
|
||||||
|
|
||||||
class TestCorrectedCommand(object):
|
class TestCorrectedCommand(object):
|
||||||
|
@ -3,7 +3,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from six import text_type
|
from six import text_type
|
||||||
from . import const
|
from . import const
|
||||||
from .utils import Path
|
from .system import Path
|
||||||
|
|
||||||
|
|
||||||
class Settings(dict):
|
class Settings(dict):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from .conf import settings
|
from .conf import settings
|
||||||
from .types import Rule
|
from .types import Rule
|
||||||
from .utils import Path
|
from .system import Path
|
||||||
from . import logs
|
from . import logs
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from thefuck.utils import for_app, replace_command, eager, memoize, Path
|
from thefuck.utils import for_app, replace_command, eager, memoize
|
||||||
|
from thefuck.system import Path
|
||||||
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
|
@ -33,3 +33,8 @@ def get_key():
|
|||||||
return const.KEY_DOWN
|
return const.KEY_DOWN
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pathlib import Path
|
||||||
|
except ImportError:
|
||||||
|
from pathlib2 import Path
|
||||||
|
@ -25,3 +25,15 @@ def get_key():
|
|||||||
|
|
||||||
encoding = sys.stdout.encoding or os.environ.get('PYTHONIOENCODING', 'utf-8')
|
encoding = sys.stdout.encoding or os.environ.get('PYTHONIOENCODING', 'utf-8')
|
||||||
return ch.decode(encoding)
|
return ch.decode(encoding)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pathlib import Path
|
||||||
|
except ImportError:
|
||||||
|
from pathlib2 import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _expanduser(self):
|
||||||
|
return self.__class__(os.path.expanduser(str(self)))
|
||||||
|
|
||||||
|
# pathlib's expanduser fails on windows, see http://bugs.python.org/issue19776
|
||||||
|
Path.expanduser = _expanduser
|
||||||
|
@ -9,11 +9,8 @@ from decorator import decorator
|
|||||||
from difflib import get_close_matches
|
from difflib import get_close_matches
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
|
from .conf import settings
|
||||||
try:
|
from .system import Path
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
|
|
||||||
DEVNULL = open(os.devnull, 'w')
|
DEVNULL = open(os.devnull, 'w')
|
||||||
|
|
||||||
@ -81,8 +78,6 @@ def default_settings(params):
|
|||||||
print(settings.apt)
|
print(settings.apt)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from .conf import settings
|
|
||||||
|
|
||||||
def _default_settings(fn, command):
|
def _default_settings(fn, command):
|
||||||
for k, w in params.items():
|
for k, w in params.items():
|
||||||
settings.setdefault(k, w)
|
settings.setdefault(k, w)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user