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

#N/A: Improve how version is fetched for all shells (#920)

This commit is contained in:
Pablo Aguiar
2019-05-27 18:24:55 +02:00
committed by Vladimir Iakovlev
parent ba949f7fd9
commit ff2944086d
12 changed files with 137 additions and 23 deletions

View File

@@ -11,6 +11,11 @@ class TestBash(object):
def shell(self):
return Bash()
@pytest.fixture(autouse=True)
def Popen(self, mocker):
mock = mocker.patch('thefuck.shells.bash.Popen')
return mock
@pytest.fixture(autouse=True)
def shell_aliases(self):
os.environ['TF_SHELL_ALIASES'] = (
@@ -74,7 +79,12 @@ class TestBash(object):
config_exists.return_value = False
assert not shell.how_to_configure().can_configure_automatically
def test_info(self, shell, mocker):
patch = mocker.patch('thefuck.shells.bash.Popen')
patch.return_value.stdout.read.side_effect = [b'3.5.9']
def test_info(self, shell, Popen):
Popen.return_value.stdout.read.side_effect = [b'3.5.9']
assert shell.info() == 'Bash 3.5.9'
def test_get_version_error(self, shell, Popen):
Popen.return_value.stdout.read.side_effect = OSError
with pytest.raises(OSError):
shell._get_version()
assert Popen.call_args[0][0] == ['bash', '-c', 'echo $BASH_VERSION']