1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/tests/rules/test_prove_recursively.py

41 lines
1.1 KiB
Python
Raw Normal View History

2017-10-15 14:51:09 +01:00
import pytest
from thefuck.rules.prove_recursively import match, get_new_command
from thefuck.types import Command
output = '''Files=0, Tests=0, 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
Result: NOTESTS'''
@pytest.fixture
def isdir(mocker):
return mocker.patch('thefuck.rules.prove_recursively'
'.os.path.isdir')
@pytest.mark.parametrize('script, output', [
('prove -lv t', output),
('prove app/t', output)])
def test_match(isdir, script, output):
isdir.return_value = True
command = Command(script, output)
assert match(command)
@pytest.mark.parametrize('script, output, isdir_result', [
('prove -lv t', output, False),
('prove -r t', output, True),
('prove --recurse t', output, True)])
def test_not_match(isdir, script, output, isdir_result):
isdir.return_value = isdir_result
command = Command(script, output)
assert not match(command)
@pytest.mark.parametrize('before, after', [
('prove -lv t', 'prove -r -lv t'),
('prove t', 'prove -r t')])
def test_get_new_command(before, after):
command = Command(before, output)
assert get_new_command(command) == after