mirror of
https://github.com/nvbn/thefuck.git
synced 2025-10-08 04:44:00 +01:00
#682: Unify work with output in classic and instant mode
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import pytest
|
||||
from thefuck.rules.git_branch_exists import match, get_new_command
|
||||
from tests.utils import Command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def stderr(branch_name):
|
||||
def output(branch_name):
|
||||
return "fatal: A branch named '{}' already exists.".format(branch_name)
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@ def new_command(branch_name):
|
||||
|
||||
@pytest.mark.parametrize('script, branch_name', [
|
||||
('git branch foo', 'foo'), ('git checkout bar', 'bar')])
|
||||
def test_match(stderr, script, branch_name):
|
||||
assert match(Command(script=script, stderr=stderr))
|
||||
def test_match(output, script, branch_name):
|
||||
assert match(Command(script, output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script', ['git branch foo', 'git checkout bar'])
|
||||
def test_not_match(script):
|
||||
assert not match(Command(script=script, stderr=''))
|
||||
assert not match(Command(script, ''))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, branch_name, ', [
|
||||
('git branch foo', 'foo'), ('git checkout bar', 'bar')])
|
||||
def test_get_new_command(stderr, new_command, script, branch_name):
|
||||
assert get_new_command(Command(script=script, stderr=stderr)) == new_command
|
||||
def test_get_new_command(output, new_command, script, branch_name):
|
||||
assert get_new_command(Command(script, output)) == new_command
|
||||
|
Reference in New Issue
Block a user