diff --git a/tests/rules/test_ssh_known_host.py b/tests/rules/test_ssh_known_host.py index 8875bd44..ed414bc1 100644 --- a/tests/rules/test_ssh_known_host.py +++ b/tests/rules/test_ssh_known_host.py @@ -2,7 +2,7 @@ import os import pytest from mock import Mock from thefuck.rules.ssh_known_hosts import match, get_new_command,\ - remove_offending_keys + side_effect from tests.utils import Command @@ -53,18 +53,14 @@ def test_match(ssh_error): assert not match(Command('ssh'), None) -def test_remove_offending_keys(ssh_error): +def test_side_effect(ssh_error): errormsg, path, reset, known_hosts = ssh_error command = Command('ssh user@host', stderr=errormsg) - remove_offending_keys(command, None) + side_effect(command, None) expected = ['123.234.567.890 asdjkasjdakjsd\n', '111.222.333.444 qwepoiwqepoiss\n'] assert known_hosts(path) == expected def test_get_new_command(ssh_error, monkeypatch): errormsg, _, _, _ = ssh_error - - method = Mock() - monkeypatch.setattr('thefuck.rules.ssh_known_hosts.remove_offending_keys', method) assert get_new_command(Command('ssh user@host', stderr=errormsg), None) == 'ssh user@host' - assert method.call_count diff --git a/thefuck/rules/ssh_known_hosts.py b/thefuck/rules/ssh_known_hosts.py index ab73c422..4e889696 100644 --- a/thefuck/rules/ssh_known_hosts.py +++ b/thefuck/rules/ssh_known_hosts.py @@ -22,7 +22,11 @@ def match(command, settings): return True -def remove_offending_keys(command, settings): +def get_new_command(command, settings): + return command.script + + +def side_effect(command, settings): offending = offending_pattern.findall(command.stderr) for filepath, lineno in offending: with open(filepath, 'r') as fh: @@ -30,8 +34,3 @@ def remove_offending_keys(command, settings): del lines[int(lineno) - 1] with open(filepath, 'w') as fh: fh.writelines(lines) - - -def get_new_command(command, settings): - remove_offending_keys(command, settings) - return command.script