mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#682: Disable instant mode on Python 2
This commit is contained in:
parent
1132015e60
commit
7a57355e7e
@ -110,12 +110,12 @@ class TestCommand(object):
|
||||
Popen = Mock()
|
||||
Popen.return_value.stdout.read.return_value = b'stdout'
|
||||
Popen.return_value.stderr.read.return_value = b'stderr'
|
||||
monkeypatch.setattr('thefuck.output.rerun.Popen', Popen)
|
||||
monkeypatch.setattr('thefuck.output_readers.rerun.Popen', Popen)
|
||||
return Popen
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def prepare(self, monkeypatch):
|
||||
monkeypatch.setattr('thefuck.output.rerun._wait_output',
|
||||
monkeypatch.setattr('thefuck.output_readers.rerun._wait_output',
|
||||
lambda *_: True)
|
||||
|
||||
def test_from_script_calls(self, Popen, settings, os_environ):
|
||||
|
@ -3,7 +3,16 @@ from . import read_log, rerun
|
||||
|
||||
|
||||
def get_output(script, expanded):
|
||||
"""Get output of the script.
|
||||
|
||||
:param script: Console script.
|
||||
:type script: str
|
||||
:param expanded: Console script with expanded aliases.
|
||||
:type expanded: str
|
||||
:rtype: (str, str)
|
||||
|
||||
"""
|
||||
if settings.instant_mode:
|
||||
return read_log.get_output(script, expanded)
|
||||
return read_log.get_output(script)
|
||||
else:
|
||||
return rerun.get_output(script, expanded)
|
||||
|
@ -5,6 +5,7 @@ try:
|
||||
except ImportError:
|
||||
from backports.shutil_get_terminal_size import get_terminal_size
|
||||
from warnings import warn
|
||||
import six
|
||||
import pyte
|
||||
from ..exceptions import ScriptNotInLog
|
||||
from .. import const
|
||||
@ -53,7 +54,17 @@ def _get_output_lines(script, log_file):
|
||||
return screen.display
|
||||
|
||||
|
||||
def get_output(script, _):
|
||||
def get_output(script):
|
||||
"""Reads script output from log.
|
||||
|
||||
:type script: str
|
||||
:rtype: (str, str)
|
||||
|
||||
"""
|
||||
if six.PY2:
|
||||
warn('Experimental instant mode is Python 3+ only')
|
||||
return None, None
|
||||
|
||||
if 'THEFUCK_OUTPUT_LOG' not in os.environ:
|
||||
warn("Output log isn't specified")
|
||||
return None, None
|
||||
|
@ -29,6 +29,13 @@ def _wait_output(popen, is_slow):
|
||||
|
||||
|
||||
def get_output(script, expanded):
|
||||
"""Runs the script and obtains stdin/stderr.
|
||||
|
||||
:type script: str
|
||||
:type expanded: str
|
||||
:rtype: (str, str)
|
||||
|
||||
"""
|
||||
env = dict(os.environ)
|
||||
env.update(settings.env)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user