mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
added tests for chdir.py in test_chdir.py
This commit is contained in:
parent
28aef57b75
commit
e45e772ae6
@ -199,6 +199,7 @@ following rules are enabled by default:
|
|||||||
* `cd_cs` – changes `cs` to `cd`;
|
* `cd_cs` – changes `cs` to `cd`;
|
||||||
* `cd_mkdir` – creates directories before cd'ing into them;
|
* `cd_mkdir` – creates directories before cd'ing into them;
|
||||||
* `cd_parent` – changes `cd..` to `cd ..`;
|
* `cd_parent` – changes `cd..` to `cd ..`;
|
||||||
|
* `chdir` – creates directories before changing into them using chdir;
|
||||||
* `chmod_x` – add execution bit;
|
* `chmod_x` – add execution bit;
|
||||||
* `choco_install` – append common suffixes for chocolatey packages;
|
* `choco_install` – append common suffixes for chocolatey packages;
|
||||||
* `composer_not_command` – fixes composer command name;
|
* `composer_not_command` – fixes composer command name;
|
||||||
|
25
tests/rules/test_chdir.py
Normal file
25
tests/rules/test_chdir.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.cd_mkdir import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command('chdir foo', 'cannot find the path'),
|
||||||
|
Command('chdir foo/bar', 'can\'t cd to'),
|
||||||
|
Command('chdir foo/bar', 'cannot find paht'),
|
||||||
|
Command('chdir /foo/bar/', 'can\'t cd to')])
|
||||||
|
def test_match(command):
|
||||||
|
assert match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command', [
|
||||||
|
Command('chdir foo', ''), Command('', '')])
|
||||||
|
def test_not_match(command):
|
||||||
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
|
(Command('chdir foo', ''), 'mkdir -p foo && chdir foo'),
|
||||||
|
(Command('chdir foo/bar', ''), 'mkdir -p foo/bar && chdir foo/bar')])
|
||||||
|
def test_get_new_command(command, new_command):
|
||||||
|
assert get_new_command(command) == new_command
|
@ -8,7 +8,6 @@ import colorama
|
|||||||
from .conf import settings
|
from .conf import settings
|
||||||
from . import const
|
from . import const
|
||||||
|
|
||||||
|
|
||||||
def color(color_):
|
def color(color_):
|
||||||
"""Utility for ability to disabling colored output."""
|
"""Utility for ability to disabling colored output."""
|
||||||
if settings.no_colors:
|
if settings.no_colors:
|
||||||
@ -58,7 +57,7 @@ def show_corrected_command(corrected_command):
|
|||||||
|
|
||||||
def confirm_text(corrected_command):
|
def confirm_text(corrected_command):
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
(u'{prefix}{clear}{bold}{script}{reset}{side_effect} '
|
(u'{prefix}{clear}{bold}{script}{reset}{side_effect}'
|
||||||
u'[{green}enter{reset}/{blue}↑{reset}/{blue}↓{reset}'
|
u'[{green}enter{reset}/{blue}↑{reset}/{blue}↓{reset}'
|
||||||
u'/{red}ctrl+c{reset}]').format(
|
u'/{red}ctrl+c{reset}]').format(
|
||||||
prefix=const.USER_COMMAND_MARK,
|
prefix=const.USER_COMMAND_MARK,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user