2015-08-25 14:09:47 +03:00
|
|
|
import pytest
|
|
|
|
from thefuck.specific.sudo import sudo_support
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-08-25 14:09:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
@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):
|
2015-09-07 13:00:29 +03:00
|
|
|
def fn(command):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert command == Command(called, '')
|
2015-08-27 16:52:26 +03:00
|
|
|
return return_value
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
assert sudo_support(fn)(Command(command, '')) == result
|