mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-21 04:32:37 +01:00
#298 Simplify func tests
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
from pexpect import TIMEOUT
|
||||
|
||||
|
||||
def _set_confirmation(proc, require):
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(
|
||||
u'echo "require_confirmation = {}" > ~/.thefuck/settings.py'.format(
|
||||
require))
|
||||
|
||||
|
||||
def with_confirmation(proc):
|
||||
"""Ensures that command can be fixed when confirmation enabled."""
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
_set_confirmation(proc, True)
|
||||
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
@@ -17,10 +23,10 @@ def with_confirmation(proc):
|
||||
assert proc.expect([TIMEOUT, u'test'])
|
||||
|
||||
|
||||
def history_changed(proc):
|
||||
def history_changed(proc, to=u'echo test'):
|
||||
"""Ensures that history changed."""
|
||||
proc.send('\033[A')
|
||||
assert proc.expect([TIMEOUT, u'echo test'])
|
||||
assert proc.expect([TIMEOUT, to])
|
||||
|
||||
|
||||
def history_not_changed(proc):
|
||||
@@ -31,8 +37,7 @@ def history_not_changed(proc):
|
||||
|
||||
def refuse_with_confirmation(proc):
|
||||
"""Ensures that fix can be refused when confirmation enabled."""
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
|
||||
_set_confirmation(proc, True)
|
||||
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
@@ -47,8 +52,7 @@ def refuse_with_confirmation(proc):
|
||||
|
||||
def without_confirmation(proc):
|
||||
"""Ensures that command can be fixed when confirmation disabled."""
|
||||
proc.sendline(u'mkdir -p ~/.thefuck')
|
||||
proc.sendline(u'echo "require_confirmation = False" > ~/.thefuck/settings.py')
|
||||
_set_confirmation(proc, False)
|
||||
|
||||
proc.sendline(u'ehco test')
|
||||
|
||||
|
Reference in New Issue
Block a user