mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-19 11:42:33 +01:00
Add transparent sudo support for rules where it required
This commit is contained in:
17
tests/test_utils.py
Normal file
17
tests/test_utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from mock import Mock
|
||||
from thefuck.utils import sudo_support
|
||||
from thefuck.main import Command
|
||||
|
||||
|
||||
def test_sudo_support():
|
||||
fn = Mock(return_value=True, __name__='')
|
||||
assert sudo_support(fn)(Command('sudo ls', 'out', 'err'), None)
|
||||
fn.assert_called_once_with(Command('ls', 'out', 'err'), None)
|
||||
|
||||
fn.return_value = False
|
||||
assert not sudo_support(fn)(Command('sudo ls', 'out', 'err'), None)
|
||||
|
||||
fn.return_value = 'pwd'
|
||||
assert sudo_support(fn)(Command('sudo ls', 'out', 'err'), None) == 'sudo pwd'
|
||||
|
||||
assert sudo_support(fn)(Command('ls', 'out', 'err'), None) == 'pwd'
|
Reference in New Issue
Block a user