1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/tests/specific/test_sudo.py
2017-08-31 17:58:56 +02:00

20 lines
662 B
Python

import pytest
from thefuck.specific.sudo import sudo_support
from thefuck.types import Command
@pytest.mark.parametrize('return_value, command, called, result', [
('ls -lah', 'sudo ls', 'ls', 'sudo ls -lah'),
('ls -lah', 'ls', 'ls', 'ls -lah'),
(['ls -lah'], 'sudo ls', 'ls', ['sudo ls -lah']),
(True, 'sudo ls', 'ls', True),
(True, 'ls', 'ls', True),
(False, 'sudo ls', 'ls', False),
(False, 'ls', 'ls', False)])
def test_sudo_support(return_value, command, called, result):
def fn(command):
assert command == Command(called, '')
return return_value
assert sudo_support(fn)(Command(command, '')) == result