1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

added tests for chdir.py in test_chdir.py

This commit is contained in:
ICalhoun 2021-04-13 15:58:20 -04:00
parent 28aef57b75
commit e45e772ae6
3 changed files with 27 additions and 2 deletions

View File

@ -199,6 +199,7 @@ following rules are enabled by default:
* `cd_cs` – changes `cs` to `cd`;
* `cd_mkdir` – creates directories before cd'ing into them;
* `cd_parent` – changes `cd..` to `cd ..`;
* `chdir` – creates directories before changing into them using chdir;
* `chmod_x` – add execution bit;
* `choco_install` – append common suffixes for chocolatey packages;
* `composer_not_command` – fixes composer command name;

25
tests/rules/test_chdir.py Normal file
View 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

View File

@ -8,7 +8,6 @@ import colorama
from .conf import settings
from . import const
def color(color_):
"""Utility for ability to disabling colored output."""
if settings.no_colors:
@ -58,7 +57,7 @@ def show_corrected_command(corrected_command):
def confirm_text(corrected_command):
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'/{red}ctrl+c{reset}]').format(
prefix=const.USER_COMMAND_MARK,