1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00
thefuck/tests/functional/plots.py

58 lines
1.7 KiB
Python
Raw Normal View History

2015-07-25 19:02:04 +01:00
from pexpect import TIMEOUT
2015-07-24 06:04:49 +01:00
def with_confirmation(proc):
"""Ensures that command can be fixed when confirmation enabled."""
2015-07-25 01:22:05 +01:00
proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 06:04:49 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'enter'])
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
2015-07-24 06:04:49 +01:00
proc.send('\n')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'test'])
2015-07-24 06:04:49 +01:00
def history_changed(proc):
"""Ensures that history changed."""
proc.send('\033[A')
2015-07-27 15:51:33 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
def history_not_changed(proc):
"""Ensures that history not changed."""
proc.send('\033[A')
2015-07-27 15:51:33 +01:00
assert proc.expect([TIMEOUT, u'fuck'])
2015-07-24 21:14:58 +01:00
def refuse_with_confirmation(proc):
"""Ensures that fix can be refused when confirmation enabled."""
2015-07-25 01:22:05 +01:00
proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline(u'echo "require_confirmation = True" > ~/.thefuck/settings.py')
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 21:14:58 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'enter'])
assert proc.expect_exact([TIMEOUT, u'ctrl+c'])
2015-07-24 21:14:58 +01:00
proc.send('\003')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'Aborted'])
2015-07-24 21:14:58 +01:00
2015-07-24 06:04:49 +01:00
def without_confirmation(proc):
"""Ensures that command can be fixed when confirmation disabled."""
2015-07-25 01:22:05 +01:00
proc.sendline(u'mkdir -p ~/.thefuck')
proc.sendline(u'echo "require_confirmation = False" > ~/.thefuck/settings.py')
2015-07-25 01:22:05 +01:00
proc.sendline(u'ehco test')
2015-07-24 06:04:49 +01:00
2015-07-25 01:22:05 +01:00
proc.sendline(u'fuck')
2015-07-25 19:02:04 +01:00
assert proc.expect([TIMEOUT, u'echo test'])
assert proc.expect([TIMEOUT, u'test'])