From 6539c853b4838c7c6ea049604ddb5bcd024ad6ba Mon Sep 17 00:00:00 2001 From: mcarton Date: Sat, 16 May 2015 15:36:27 +0200 Subject: [PATCH 1/3] Add tests for the `whois` rule --- tests/rules/test_whois.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/rules/test_whois.py diff --git a/tests/rules/test_whois.py b/tests/rules/test_whois.py new file mode 100644 index 00000000..b911106e --- /dev/null +++ b/tests/rules/test_whois.py @@ -0,0 +1,19 @@ +import pytest +from thefuck.rules.whois import match, get_new_command +from tests.utils import Command + + +@pytest.mark.parametrize('command', [ + Command(script='whois https://en.wikipedia.org/wiki/Main_Page'), + Command(script='whois https://en.wikipedia.org/'), + Command(script='whois en.wikipedia.org')]) +def test_match(command): + assert match(command, None) + + +@pytest.mark.parametrize('command, new_command', [ + (Command('whois https://en.wikipedia.org/wiki/Main_Page'), 'whois en.wikipedia.org'), + (Command('whois https://en.wikipedia.org/'), 'whois en.wikipedia.org'), + (Command('whois en.wikipedia.org'), 'whois wikipedia.org')]) +def test_get_new_command(command, new_command): + assert get_new_command(command, None) == new_command From bb4b42d2f1b483a263937e7c90253bfb476df0e6 Mon Sep 17 00:00:00 2001 From: mcarton Date: Sat, 16 May 2015 15:37:00 +0200 Subject: [PATCH 2/3] Add the `whois` rule in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9cf7237f..1ac70f45 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `ssh_known_hosts` – removes host from `known_hosts` on warning; * `sudo` – prepends `sudo` to previous command if it failed because of permissions; * `switch_layout` – switches command from your local layout to en; +* `whois` – fixes `whois` command; * `apt_get` – installs app from apt if it not installed; * `brew_install` – fixes formula name for `brew install`; * `composer_not_command` – fixes composer command name. From f04c4396eb3cb75cf9f3a9e25ece51d2cc9f50c2 Mon Sep 17 00:00:00 2001 From: mcarton Date: Sat, 16 May 2015 18:57:42 +0200 Subject: [PATCH 3/3] Fix Python 2.7 support --- thefuck/rules/whois.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thefuck/rules/whois.py b/thefuck/rules/whois.py index f019758e..f53cdde8 100644 --- a/thefuck/rules/whois.py +++ b/thefuck/rules/whois.py @@ -1,4 +1,5 @@ -from urllib.parse import urlparse +# -*- encoding: utf-8 -*- +from six.moves.urllib.parse import urlparse def match(command, settings):